ELF2: Implement --gc-sections.
Section garbage collection is a feature to remove unused sections
from outputs. Unused sections are sections that cannot be reachable
from known GC-root symbols or sections. Naturally the feature is
implemented as a mark-sweep garbage collector.
In this patch, I added Live bit to InputSectionBase. If and only
if Live bit is on, the section will be written to the output.
Starting from GC-root symbols or sections, a new function, markLive(),
visits all reachable sections and sets their Live bits. Writer then
ignores sections whose Live bit is off, so that such sections are
excluded from the output.
This change has small negative impact on performance if you use
the feature because making sections means more work. The time to
link Clang changes from 0.356s to 0.386s, or +8%.
It reduces Clang size from 57,764,984 bytes to 55,296,600 bytes.
That is 4.3% reduction.
http://reviews.llvm.org/D13950
llvm-svn: 251043
2015-10-23 02:49:53 +08:00
|
|
|
# REQUIRES: x86
|
|
|
|
|
|
|
|
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
|
2015-11-18 14:11:01 +08:00
|
|
|
# RUN: ld.lld %t -o %t2
|
2019-05-01 13:49:01 +08:00
|
|
|
# RUN: llvm-readobj --sections --symbols %t2 | FileCheck -check-prefix=NOGC %s
|
2015-11-18 14:11:01 +08:00
|
|
|
# RUN: ld.lld --gc-sections %t -o %t2
|
2019-05-01 13:49:01 +08:00
|
|
|
# RUN: llvm-readobj --sections --symbols %t2 | FileCheck -check-prefix=GC1 %s
|
2015-11-18 14:11:01 +08:00
|
|
|
# RUN: ld.lld --export-dynamic --gc-sections %t -o %t2
|
2019-05-01 13:49:01 +08:00
|
|
|
# RUN: llvm-readobj --sections --symbols %t2 | FileCheck -check-prefix=GC2 %s
|
ELF2: Implement --gc-sections.
Section garbage collection is a feature to remove unused sections
from outputs. Unused sections are sections that cannot be reachable
from known GC-root symbols or sections. Naturally the feature is
implemented as a mark-sweep garbage collector.
In this patch, I added Live bit to InputSectionBase. If and only
if Live bit is on, the section will be written to the output.
Starting from GC-root symbols or sections, a new function, markLive(),
visits all reachable sections and sets their Live bits. Writer then
ignores sections whose Live bit is off, so that such sections are
excluded from the output.
This change has small negative impact on performance if you use
the feature because making sections means more work. The time to
link Clang changes from 0.356s to 0.386s, or +8%.
It reduces Clang size from 57,764,984 bytes to 55,296,600 bytes.
That is 4.3% reduction.
http://reviews.llvm.org/D13950
llvm-svn: 251043
2015-10-23 02:49:53 +08:00
|
|
|
|
2015-10-23 05:42:05 +08:00
|
|
|
# NOGC: Name: .eh_frame
|
2015-11-06 23:25:54 +08:00
|
|
|
# NOGC: Name: .text
|
ELF2: Implement --gc-sections.
Section garbage collection is a feature to remove unused sections
from outputs. Unused sections are sections that cannot be reachable
from known GC-root symbols or sections. Naturally the feature is
implemented as a mark-sweep garbage collector.
In this patch, I added Live bit to InputSectionBase. If and only
if Live bit is on, the section will be written to the output.
Starting from GC-root symbols or sections, a new function, markLive(),
visits all reachable sections and sets their Live bits. Writer then
ignores sections whose Live bit is off, so that such sections are
excluded from the output.
This change has small negative impact on performance if you use
the feature because making sections means more work. The time to
link Clang changes from 0.356s to 0.386s, or +8%.
It reduces Clang size from 57,764,984 bytes to 55,296,600 bytes.
That is 4.3% reduction.
http://reviews.llvm.org/D13950
llvm-svn: 251043
2015-10-23 02:49:53 +08:00
|
|
|
# NOGC: Name: .init
|
|
|
|
# NOGC: Name: .fini
|
2020-08-27 00:06:41 +08:00
|
|
|
# NOGC: Name: .tdata
|
|
|
|
# NOGC: Name: .tbss
|
2017-05-27 01:23:25 +08:00
|
|
|
# NOGC: Name: .ctors
|
|
|
|
# NOGC: Name: .dtors
|
2016-09-26 16:32:41 +08:00
|
|
|
# NOGC: Name: .debug_pubtypes
|
|
|
|
# NOGC: Name: .comment
|
ELF2: Implement --gc-sections.
Section garbage collection is a feature to remove unused sections
from outputs. Unused sections are sections that cannot be reachable
from known GC-root symbols or sections. Naturally the feature is
implemented as a mark-sweep garbage collector.
In this patch, I added Live bit to InputSectionBase. If and only
if Live bit is on, the section will be written to the output.
Starting from GC-root symbols or sections, a new function, markLive(),
visits all reachable sections and sets their Live bits. Writer then
ignores sections whose Live bit is off, so that such sections are
excluded from the output.
This change has small negative impact on performance if you use
the feature because making sections means more work. The time to
link Clang changes from 0.356s to 0.386s, or +8%.
It reduces Clang size from 57,764,984 bytes to 55,296,600 bytes.
That is 4.3% reduction.
http://reviews.llvm.org/D13950
llvm-svn: 251043
2015-10-23 02:49:53 +08:00
|
|
|
# NOGC: Name: a
|
|
|
|
# NOGC: Name: b
|
|
|
|
# NOGC: Name: c
|
2020-08-27 00:06:41 +08:00
|
|
|
# NOGC: Name: e
|
|
|
|
# NOGC: Name: f
|
|
|
|
# NOGC: Name: g
|
|
|
|
# NOGC: Name: h
|
ELF2: Implement --gc-sections.
Section garbage collection is a feature to remove unused sections
from outputs. Unused sections are sections that cannot be reachable
from known GC-root symbols or sections. Naturally the feature is
implemented as a mark-sweep garbage collector.
In this patch, I added Live bit to InputSectionBase. If and only
if Live bit is on, the section will be written to the output.
Starting from GC-root symbols or sections, a new function, markLive(),
visits all reachable sections and sets their Live bits. Writer then
ignores sections whose Live bit is off, so that such sections are
excluded from the output.
This change has small negative impact on performance if you use
the feature because making sections means more work. The time to
link Clang changes from 0.356s to 0.386s, or +8%.
It reduces Clang size from 57,764,984 bytes to 55,296,600 bytes.
That is 4.3% reduction.
http://reviews.llvm.org/D13950
llvm-svn: 251043
2015-10-23 02:49:53 +08:00
|
|
|
# NOGC: Name: x
|
|
|
|
# NOGC: Name: y
|
|
|
|
# NOGC: Name: d
|
|
|
|
|
2015-10-23 05:42:05 +08:00
|
|
|
# GC1: Name: .eh_frame
|
2015-11-06 23:25:54 +08:00
|
|
|
# GC1: Name: .text
|
ELF2: Implement --gc-sections.
Section garbage collection is a feature to remove unused sections
from outputs. Unused sections are sections that cannot be reachable
from known GC-root symbols or sections. Naturally the feature is
implemented as a mark-sweep garbage collector.
In this patch, I added Live bit to InputSectionBase. If and only
if Live bit is on, the section will be written to the output.
Starting from GC-root symbols or sections, a new function, markLive(),
visits all reachable sections and sets their Live bits. Writer then
ignores sections whose Live bit is off, so that such sections are
excluded from the output.
This change has small negative impact on performance if you use
the feature because making sections means more work. The time to
link Clang changes from 0.356s to 0.386s, or +8%.
It reduces Clang size from 57,764,984 bytes to 55,296,600 bytes.
That is 4.3% reduction.
http://reviews.llvm.org/D13950
llvm-svn: 251043
2015-10-23 02:49:53 +08:00
|
|
|
# GC1: Name: .init
|
|
|
|
# GC1: Name: .fini
|
2020-08-27 00:06:41 +08:00
|
|
|
# GC1: Name: .tdata
|
|
|
|
# GC1: Name: .tbss
|
2017-05-27 01:23:25 +08:00
|
|
|
# GC1: Name: .ctors
|
|
|
|
# GC1: Name: .dtors
|
2016-09-26 16:32:41 +08:00
|
|
|
# GC1: Name: .debug_pubtypes
|
|
|
|
# GC1: Name: .comment
|
ELF2: Implement --gc-sections.
Section garbage collection is a feature to remove unused sections
from outputs. Unused sections are sections that cannot be reachable
from known GC-root symbols or sections. Naturally the feature is
implemented as a mark-sweep garbage collector.
In this patch, I added Live bit to InputSectionBase. If and only
if Live bit is on, the section will be written to the output.
Starting from GC-root symbols or sections, a new function, markLive(),
visits all reachable sections and sets their Live bits. Writer then
ignores sections whose Live bit is off, so that such sections are
excluded from the output.
This change has small negative impact on performance if you use
the feature because making sections means more work. The time to
link Clang changes from 0.356s to 0.386s, or +8%.
It reduces Clang size from 57,764,984 bytes to 55,296,600 bytes.
That is 4.3% reduction.
http://reviews.llvm.org/D13950
llvm-svn: 251043
2015-10-23 02:49:53 +08:00
|
|
|
# GC1: Name: a
|
|
|
|
# GC1: Name: b
|
|
|
|
# GC1: Name: c
|
2020-08-27 00:06:41 +08:00
|
|
|
# GC1: Name: e
|
|
|
|
# GC1-NOT: Name: f
|
|
|
|
# GC1: Name: g
|
|
|
|
# GC1-NOT: Name: h
|
ELF2: Implement --gc-sections.
Section garbage collection is a feature to remove unused sections
from outputs. Unused sections are sections that cannot be reachable
from known GC-root symbols or sections. Naturally the feature is
implemented as a mark-sweep garbage collector.
In this patch, I added Live bit to InputSectionBase. If and only
if Live bit is on, the section will be written to the output.
Starting from GC-root symbols or sections, a new function, markLive(),
visits all reachable sections and sets their Live bits. Writer then
ignores sections whose Live bit is off, so that such sections are
excluded from the output.
This change has small negative impact on performance if you use
the feature because making sections means more work. The time to
link Clang changes from 0.356s to 0.386s, or +8%.
It reduces Clang size from 57,764,984 bytes to 55,296,600 bytes.
That is 4.3% reduction.
http://reviews.llvm.org/D13950
llvm-svn: 251043
2015-10-23 02:49:53 +08:00
|
|
|
# GC1-NOT: Name: x
|
|
|
|
# GC1-NOT: Name: y
|
|
|
|
# GC1-NOT: Name: d
|
|
|
|
|
2015-10-23 05:42:05 +08:00
|
|
|
# GC2: Name: .eh_frame
|
2015-11-06 23:25:54 +08:00
|
|
|
# GC2: Name: .text
|
ELF2: Implement --gc-sections.
Section garbage collection is a feature to remove unused sections
from outputs. Unused sections are sections that cannot be reachable
from known GC-root symbols or sections. Naturally the feature is
implemented as a mark-sweep garbage collector.
In this patch, I added Live bit to InputSectionBase. If and only
if Live bit is on, the section will be written to the output.
Starting from GC-root symbols or sections, a new function, markLive(),
visits all reachable sections and sets their Live bits. Writer then
ignores sections whose Live bit is off, so that such sections are
excluded from the output.
This change has small negative impact on performance if you use
the feature because making sections means more work. The time to
link Clang changes from 0.356s to 0.386s, or +8%.
It reduces Clang size from 57,764,984 bytes to 55,296,600 bytes.
That is 4.3% reduction.
http://reviews.llvm.org/D13950
llvm-svn: 251043
2015-10-23 02:49:53 +08:00
|
|
|
# GC2: Name: .init
|
|
|
|
# GC2: Name: .fini
|
2020-08-27 00:06:41 +08:00
|
|
|
# GC2: Name: .tdata
|
|
|
|
# GC2: Name: .tbss
|
2017-05-27 01:23:25 +08:00
|
|
|
# GC2: Name: .ctors
|
|
|
|
# GC2: Name: .dtors
|
2016-09-26 16:32:41 +08:00
|
|
|
# GC2: Name: .debug_pubtypes
|
|
|
|
# GC2: Name: .comment
|
ELF2: Implement --gc-sections.
Section garbage collection is a feature to remove unused sections
from outputs. Unused sections are sections that cannot be reachable
from known GC-root symbols or sections. Naturally the feature is
implemented as a mark-sweep garbage collector.
In this patch, I added Live bit to InputSectionBase. If and only
if Live bit is on, the section will be written to the output.
Starting from GC-root symbols or sections, a new function, markLive(),
visits all reachable sections and sets their Live bits. Writer then
ignores sections whose Live bit is off, so that such sections are
excluded from the output.
This change has small negative impact on performance if you use
the feature because making sections means more work. The time to
link Clang changes from 0.356s to 0.386s, or +8%.
It reduces Clang size from 57,764,984 bytes to 55,296,600 bytes.
That is 4.3% reduction.
http://reviews.llvm.org/D13950
llvm-svn: 251043
2015-10-23 02:49:53 +08:00
|
|
|
# GC2: Name: a
|
|
|
|
# GC2: Name: b
|
|
|
|
# GC2: Name: c
|
2020-08-27 00:06:41 +08:00
|
|
|
# GC2: Name: e
|
|
|
|
# GC2-NOT: Name: f
|
|
|
|
# GC2: Name: g
|
|
|
|
# GC2-NOT: Name: h
|
ELF2: Implement --gc-sections.
Section garbage collection is a feature to remove unused sections
from outputs. Unused sections are sections that cannot be reachable
from known GC-root symbols or sections. Naturally the feature is
implemented as a mark-sweep garbage collector.
In this patch, I added Live bit to InputSectionBase. If and only
if Live bit is on, the section will be written to the output.
Starting from GC-root symbols or sections, a new function, markLive(),
visits all reachable sections and sets their Live bits. Writer then
ignores sections whose Live bit is off, so that such sections are
excluded from the output.
This change has small negative impact on performance if you use
the feature because making sections means more work. The time to
link Clang changes from 0.356s to 0.386s, or +8%.
It reduces Clang size from 57,764,984 bytes to 55,296,600 bytes.
That is 4.3% reduction.
http://reviews.llvm.org/D13950
llvm-svn: 251043
2015-10-23 02:49:53 +08:00
|
|
|
# GC2-NOT: Name: x
|
|
|
|
# GC2-NOT: Name: y
|
|
|
|
# GC2: Name: d
|
|
|
|
|
|
|
|
.globl _start, d
|
2020-08-27 00:06:41 +08:00
|
|
|
.protected a, b, c, e, f, g, h, x, y
|
ELF2: Implement --gc-sections.
Section garbage collection is a feature to remove unused sections
from outputs. Unused sections are sections that cannot be reachable
from known GC-root symbols or sections. Naturally the feature is
implemented as a mark-sweep garbage collector.
In this patch, I added Live bit to InputSectionBase. If and only
if Live bit is on, the section will be written to the output.
Starting from GC-root symbols or sections, a new function, markLive(),
visits all reachable sections and sets their Live bits. Writer then
ignores sections whose Live bit is off, so that such sections are
excluded from the output.
This change has small negative impact on performance if you use
the feature because making sections means more work. The time to
link Clang changes from 0.356s to 0.386s, or +8%.
It reduces Clang size from 57,764,984 bytes to 55,296,600 bytes.
That is 4.3% reduction.
http://reviews.llvm.org/D13950
llvm-svn: 251043
2015-10-23 02:49:53 +08:00
|
|
|
_start:
|
|
|
|
call a
|
|
|
|
|
|
|
|
.section .text.a,"ax",@progbits
|
|
|
|
a:
|
|
|
|
call _start
|
|
|
|
call b
|
|
|
|
|
|
|
|
.section .text.b,"ax",@progbits
|
|
|
|
b:
|
2020-08-27 00:06:41 +08:00
|
|
|
leaq e@tpoff(%rax),%rdx
|
ELF2: Implement --gc-sections.
Section garbage collection is a feature to remove unused sections
from outputs. Unused sections are sections that cannot be reachable
from known GC-root symbols or sections. Naturally the feature is
implemented as a mark-sweep garbage collector.
In this patch, I added Live bit to InputSectionBase. If and only
if Live bit is on, the section will be written to the output.
Starting from GC-root symbols or sections, a new function, markLive(),
visits all reachable sections and sets their Live bits. Writer then
ignores sections whose Live bit is off, so that such sections are
excluded from the output.
This change has small negative impact on performance if you use
the feature because making sections means more work. The time to
link Clang changes from 0.356s to 0.386s, or +8%.
It reduces Clang size from 57,764,984 bytes to 55,296,600 bytes.
That is 4.3% reduction.
http://reviews.llvm.org/D13950
llvm-svn: 251043
2015-10-23 02:49:53 +08:00
|
|
|
call c
|
|
|
|
|
|
|
|
.section .text.c,"ax",@progbits
|
|
|
|
c:
|
2020-08-27 00:06:41 +08:00
|
|
|
leaq g@tpoff(%rax),%rdx
|
ELF2: Implement --gc-sections.
Section garbage collection is a feature to remove unused sections
from outputs. Unused sections are sections that cannot be reachable
from known GC-root symbols or sections. Naturally the feature is
implemented as a mark-sweep garbage collector.
In this patch, I added Live bit to InputSectionBase. If and only
if Live bit is on, the section will be written to the output.
Starting from GC-root symbols or sections, a new function, markLive(),
visits all reachable sections and sets their Live bits. Writer then
ignores sections whose Live bit is off, so that such sections are
excluded from the output.
This change has small negative impact on performance if you use
the feature because making sections means more work. The time to
link Clang changes from 0.356s to 0.386s, or +8%.
It reduces Clang size from 57,764,984 bytes to 55,296,600 bytes.
That is 4.3% reduction.
http://reviews.llvm.org/D13950
llvm-svn: 251043
2015-10-23 02:49:53 +08:00
|
|
|
|
|
|
|
.section .text.d,"ax",@progbits
|
|
|
|
d:
|
|
|
|
nop
|
|
|
|
|
|
|
|
.section .text.x,"ax",@progbits
|
|
|
|
x:
|
|
|
|
call y
|
|
|
|
|
|
|
|
.section .text.y,"ax",@progbits
|
|
|
|
y:
|
|
|
|
call x
|
|
|
|
|
2020-08-27 00:06:41 +08:00
|
|
|
.section .tbss.e,"awT",@nobits
|
|
|
|
e:
|
|
|
|
.quad 0
|
|
|
|
|
|
|
|
.section .tbss.f,"awT",@nobits
|
|
|
|
f:
|
|
|
|
.quad 0
|
|
|
|
|
|
|
|
.section .tdata.g,"awT",@progbits
|
|
|
|
g:
|
|
|
|
.quad 0
|
|
|
|
|
|
|
|
.section .tdata.h,"awT",@progbits
|
|
|
|
h:
|
|
|
|
.quad 0
|
|
|
|
|
2015-12-24 17:52:11 +08:00
|
|
|
.section .ctors,"aw",@progbits
|
|
|
|
.quad 0
|
|
|
|
|
|
|
|
.section .dtors,"aw",@progbits
|
|
|
|
.quad 0
|
|
|
|
|
ELF2: Implement --gc-sections.
Section garbage collection is a feature to remove unused sections
from outputs. Unused sections are sections that cannot be reachable
from known GC-root symbols or sections. Naturally the feature is
implemented as a mark-sweep garbage collector.
In this patch, I added Live bit to InputSectionBase. If and only
if Live bit is on, the section will be written to the output.
Starting from GC-root symbols or sections, a new function, markLive(),
visits all reachable sections and sets their Live bits. Writer then
ignores sections whose Live bit is off, so that such sections are
excluded from the output.
This change has small negative impact on performance if you use
the feature because making sections means more work. The time to
link Clang changes from 0.356s to 0.386s, or +8%.
It reduces Clang size from 57,764,984 bytes to 55,296,600 bytes.
That is 4.3% reduction.
http://reviews.llvm.org/D13950
llvm-svn: 251043
2015-10-23 02:49:53 +08:00
|
|
|
.section .init,"aw",@init_array
|
|
|
|
.quad 0
|
|
|
|
|
|
|
|
.section .fini,"aw",@fini_array
|
|
|
|
.quad 0
|
|
|
|
|
|
|
|
.section .preinit_array,"aw",@preinit_array
|
|
|
|
.quad 0
|
2015-10-23 05:42:05 +08:00
|
|
|
|
2015-11-06 23:25:54 +08:00
|
|
|
.section .eh_frame,"a",@unwind
|
2015-10-23 05:42:05 +08:00
|
|
|
.quad 0
|
2016-09-26 16:32:41 +08:00
|
|
|
|
|
|
|
.section .debug_pubtypes,"",@progbits
|
|
|
|
.quad 0
|
|
|
|
|
|
|
|
.section .comment,"MS",@progbits,8
|
|
|
|
.quad 0
|