[PATCH] D17857: [ELF] - DT_TEXTREL/DF_TEXTREL flags implemented.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 3 12:29:11 PST 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL262650: [ELF] - Do not allow .bss to occupy the file space when producing relocatable… (authored by grimar).
Changed prior to commit:
http://reviews.llvm.org/D17857?vs=49750&id=49767#toc
Repository:
rL LLVM
http://reviews.llvm.org/D17857
Files:
lld/trunk/ELF/Writer.cpp
lld/trunk/test/ELF/relocatable-bss.s
lld/trunk/test/ELF/relocatable.s
Index: lld/trunk/test/ELF/relocatable-bss.s
===================================================================
--- lld/trunk/test/ELF/relocatable-bss.s
+++ lld/trunk/test/ELF/relocatable-bss.s
@@ -0,0 +1,40 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.o
+# RUN: ld.lld -r %t1.o -o %t
+# RUN: llvm-readobj -file-headers -sections -program-headers -symbols -r %t | FileCheck %s
+
+## We check here that .bss does not occupy the space in file.
+## If it would, the SectionHeaderOffset would have offset about 5 megabytes.
+# CHECK: ElfHeader {
+# CHECK-NEXT: Ident {
+# CHECK-NEXT: Magic: (7F 45 4C 46)
+# CHECK-NEXT: Class: 64-bit
+# CHECK-NEXT: DataEncoding: LittleEndian
+# CHECK-NEXT: FileVersion: 1
+# CHECK-NEXT: OS/ABI: SystemV
+# CHECK-NEXT: ABIVersion: 0
+# CHECK-NEXT: Unused: (00 00 00 00 00 00 00)
+# CHECK-NEXT: }
+# CHECK-NEXT: Type: Relocatable
+# CHECK-NEXT: Machine: EM_X86_64
+# CHECK-NEXT: Version:
+# CHECK-NEXT: Entry:
+# CHECK-NEXT: ProgramHeaderOffset:
+# CHECK-NEXT: SectionHeaderOffset: 0xA8
+# CHECK-NEXT: Flags [
+# CHECK-NEXT: ]
+# CHECK-NEXT: HeaderSize:
+# CHECK-NEXT: ProgramHeaderEntrySize:
+# CHECK-NEXT: ProgramHeaderCount:
+# CHECK-NEXT: SectionHeaderEntrySize:
+# CHECK-NEXT: SectionHeaderCount:
+# CHECK-NEXT: StringTableSectionIndex:
+# CHECK-NEXT: }
+
+.text
+.globl _start;
+_start:
+ nop
+
+.bss
+ .space 5242880
Index: lld/trunk/test/ELF/relocatable.s
===================================================================
--- lld/trunk/test/ELF/relocatable.s
+++ lld/trunk/test/ELF/relocatable.s
@@ -30,7 +30,7 @@
# CHECK-NEXT: Version: 1
# CHECK-NEXT: Entry: 0x0
# CHECK-NEXT: ProgramHeaderOffset: 0x0
-# CHECK-NEXT: SectionHeaderOffset: 0x2D8
+# CHECK-NEXT: SectionHeaderOffset: 0x2C0
# CHECK-NEXT: Flags [
# CHECK-NEXT: ]
# CHECK-NEXT: HeaderSize: 64
Index: lld/trunk/ELF/Writer.cpp
===================================================================
--- lld/trunk/ELF/Writer.cpp
+++ lld/trunk/ELF/Writer.cpp
@@ -1327,9 +1327,11 @@
Out<ELFT>::ElfHeader->setSize(sizeof(Elf_Ehdr));
uintX_t FileOff = 0;
for (OutputSectionBase<ELFT> *Sec : OutputSections) {
- FileOff = alignTo(FileOff, Sec->getAlign());
+ if (Sec->getType() != SHT_NOBITS)
+ FileOff = alignTo(FileOff, Sec->getAlign());
Sec->setFileOffset(FileOff);
- FileOff += Sec->getSize();
+ if (Sec->getType() != SHT_NOBITS)
+ FileOff += Sec->getSize();
}
SectionHeaderOff = alignTo(FileOff, sizeof(uintX_t));
FileSize = SectionHeaderOff + getNumSections() * sizeof(Elf_Shdr);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17857.49767.patch
Type: text/x-patch
Size: 2622 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160303/d3972bf8/attachment.bin>
More information about the llvm-commits
mailing list