[lld] r184071 - [ELF] Add more sections to the default section map.
Shankar Easwaran
shankare at codeaurora.org
Sun Jun 16 19:29:36 PDT 2013
Author: shankare
Date: Sun Jun 16 21:29:36 2013
New Revision: 184071
URL: http://llvm.org/viewvc/llvm-project?rev=184071&view=rev
Log:
[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.
Added:
lld/trunk/test/elf/X86_64/Inputs/sectionmap.c
lld/trunk/test/elf/X86_64/Inputs/sectionmap.o
lld/trunk/test/elf/X86_64/sectionmap.test
Modified:
lld/trunk/lib/ReaderWriter/ELF/DefaultLayout.h
Modified: lld/trunk/lib/ReaderWriter/ELF/DefaultLayout.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/DefaultLayout.h?rev=184071&r1=184070&r2=184071&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/DefaultLayout.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/DefaultLayout.h Sun Jun 16 21:29:36 2013
@@ -368,6 +368,14 @@ StringRef DefaultLayout<ELFT>::getSectio
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"))
Added: lld/trunk/test/elf/X86_64/Inputs/sectionmap.c
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/X86_64/Inputs/sectionmap.c?rev=184071&view=auto
==============================================================================
--- lld/trunk/test/elf/X86_64/Inputs/sectionmap.c (added)
+++ lld/trunk/test/elf/X86_64/Inputs/sectionmap.c Sun Jun 16 21:29:36 2013
@@ -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;
Added: lld/trunk/test/elf/X86_64/Inputs/sectionmap.o
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/X86_64/Inputs/sectionmap.o?rev=184071&view=auto
==============================================================================
Binary files lld/trunk/test/elf/X86_64/Inputs/sectionmap.o (added) and lld/trunk/test/elf/X86_64/Inputs/sectionmap.o Sun Jun 16 21:29:36 2013 differ
Added: lld/trunk/test/elf/X86_64/sectionmap.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/X86_64/sectionmap.test?rev=184071&view=auto
==============================================================================
--- lld/trunk/test/elf/X86_64/sectionmap.test (added)
+++ lld/trunk/test/elf/X86_64/sectionmap.test Sun Jun 16 21:29:36 2013
@@ -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: }
More information about the llvm-commits
mailing list