[ELF] Add more sections to the default section map.

This change adds functionality to add more sections like .gcc_except_table,
.data.rel.local, .data.rel.ro into the default section map, so that they are
all merged into appropriate output sections.

This also makes c++ static binaries comparable to what you get with the default
linker.

Adds a test for testing the functionality.

llvm-svn: 184071
This commit is contained in:
Shankar Easwaran 2013-06-17 02:29:36 +00:00
parent 3b08dcd4cc
commit f91031efcf
4 changed files with 39 additions and 0 deletions

View File

@ -368,6 +368,14 @@ StringRef DefaultLayout<ELFT>::getSectionName(
return ".text";
if (name.startswith(".rodata"))
return ".rodata";
if (name.startswith(".gcc_except_table"))
return ".gcc_except_table";
if (name.startswith(".data.rel.ro"))
return ".data.rel.ro";
if (name.startswith(".data.rel.local"))
return ".data.rel.local";
if (name.startswith(".data"))
return ".data";
if (name.startswith(".tdata"))
return ".tdata";
if (name.startswith(".tbss"))

View File

@ -0,0 +1,4 @@
int foo __attribute__((section(".gcc_except_table.foo"))) = 4;
const int bar __attribute__((section(".data.rel.local"))) = 2;
const int baz __attribute__((section(".data.rel.ro"))) = 2;
const int bak __attribute__((section(".data.xyz"))) = 2;

Binary file not shown.

View File

@ -0,0 +1,27 @@
# This tests that we are able to merge the section .gcc_except_table,
# .data.rel.local, .data.rel.ro, any other sections that belong to .data
# into appropriate output sections
RUN: lld -flavor gnu -target x86_64-linux %p/Inputs/sectionmap.o \
RUN: --noinhibit-exec -o %t
RUN: llvm-readobj -sections %t | FileCheck %s -check-prefix=VERIFYSECTIONHEADERS
VERIFYSECTIONHEADERS: Section {
VERIFYSECTIONHEADERS: Index: 10
VERIFYSECTIONHEADERS: Name: .data (80)
VERIFYSECTIONHEADERS: }
VERIFYSECTIONHEADERS: Section {
VERIFYSECTIONHEADERS: Index: 11
VERIFYSECTIONHEADERS: Name: .gcc_except_table (86)
VERIFYSECTIONHEADERS: }
VERIFYSECTIONHEADERS: Section {
VERIFYSECTIONHEADERS: Index: 12
VERIFYSECTIONHEADERS: Name: .data.rel.local (104)
VERIFYSECTIONHEADERS: }
VERIFYSECTIONHEADERS: Section {
VERIFYSECTIONHEADERS: Index: 13
VERIFYSECTIONHEADERS: Name: .data.rel.ro (120)
VERIFYSECTIONHEADERS: }
VERIFYSECTIONHEADERS: Section {
VERIFYSECTIONHEADERS: Index: 14
VERIFYSECTIONHEADERS: Name: .bss (133)
VERIFYSECTIONHEADERS: }