[lld] r261667 - Don't include tbss's alignment in offset.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 23 10:39:56 PST 2016
Author: rafael
Date: Tue Feb 23 12:39:55 2016
New Revision: 261667
URL: http://llvm.org/viewvc/llvm-project?rev=261667&view=rev
Log:
Don't include tbss's alignment in offset.
The .tbss section is in the middle of a PT_LOAD. Whatever treatment we
give to its address we must also give to the offset.
We were ignoring it for address computations, but not for offset.
Fixes pr26712.
Added:
lld/trunk/test/ELF/tls-offset.s
Modified:
lld/trunk/ELF/Writer.cpp
lld/trunk/test/ELF/relocation-copy-i686.s
lld/trunk/test/ELF/relocation-copy.s
lld/trunk/test/ELF/symbols.s
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=261667&r1=261666&r2=261667&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Tue Feb 23 12:39:55 2016
@@ -1344,7 +1344,8 @@ template <class ELFT> void Writer<ELFT>:
if (PageAlign.count(Sec))
Align = std::max<uintX_t>(Align, Target->PageSize);
- FileOff = alignTo(FileOff, Align);
+ if (Sec->getType() != SHT_NOBITS)
+ FileOff = alignTo(FileOff, Align);
Sec->setFileOffset(FileOff);
if (Sec->getType() != SHT_NOBITS)
FileOff += Sec->getSize();
Modified: lld/trunk/test/ELF/relocation-copy-i686.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/relocation-copy-i686.s?rev=261667&r1=261666&r2=261667&view=diff
==============================================================================
--- lld/trunk/test/ELF/relocation-copy-i686.s (original)
+++ lld/trunk/test/ELF/relocation-copy-i686.s Tue Feb 23 12:39:55 2016
@@ -22,7 +22,7 @@ movl $9, z
// CHECK-NEXT: SHF_WRITE
// CHECK-NEXT: ]
// CHECK-NEXT: Address: 0x13000
-// CHECK-NEXT: Offset: 0x3000
+// CHECK-NEXT: Offset:
// CHECK-NEXT: Size: 24
// CHECK-NEXT: Link: 0
// CHECK-NEXT: Info: 0
Modified: lld/trunk/test/ELF/relocation-copy.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/relocation-copy.s?rev=261667&r1=261666&r2=261667&view=diff
==============================================================================
--- lld/trunk/test/ELF/relocation-copy.s (original)
+++ lld/trunk/test/ELF/relocation-copy.s Tue Feb 23 12:39:55 2016
@@ -23,7 +23,7 @@ movl $z, %edx
// CHECK-NEXT: SHF_WRITE (0x1)
// CHECK-NEXT: ]
// CHECK-NEXT: Address: 0x13000
-// CHECK-NEXT: Offset: 0x3000
+// CHECK-NEXT: Offset:
// CHECK-NEXT: Size: 24
// CHECK-NEXT: Link: 0
// CHECK-NEXT: Info: 0
Modified: lld/trunk/test/ELF/symbols.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/symbols.s?rev=261667&r1=261666&r2=261667&view=diff
==============================================================================
--- lld/trunk/test/ELF/symbols.s (original)
+++ lld/trunk/test/ELF/symbols.s Tue Feb 23 12:39:55 2016
@@ -67,7 +67,7 @@ internal:
// CHECK-NEXT: SHF_WRITE
// CHECK-NEXT: ]
// CHECK-NEXT: Address: 0x12000
-// CHECK-NEXT: Offset: 0x2000
+// CHECK-NEXT: Offset:
// CHECK-NEXT: Size: 4
// CHECK: Symbols [
Added: lld/trunk/test/ELF/tls-offset.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/tls-offset.s?rev=261667&view=auto
==============================================================================
--- lld/trunk/test/ELF/tls-offset.s (added)
+++ lld/trunk/test/ELF/tls-offset.s Tue Feb 23 12:39:55 2016
@@ -0,0 +1,56 @@
+// REQUIRES: x86
+// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
+// RUN: ld.lld %t -o %tout
+// RUN: llvm-readobj -s %tout | FileCheck %s
+
+ .global _start
+_start:
+ retq
+
+ .section .tdata,"awT", at progbits
+ .align 4
+ .long 42
+
+ .section .tbss,"awT", at nobits
+ .align 16
+ .zero 16
+
+ .data
+ .long 1
+
+
+// Test that .tbss doesn't show up in the offset or in the address. If this
+// gets out of sync what we get a runtime is different from what the section
+// table says.
+
+// CHECK: Name: .tdata
+// CHECK-NEXT: Type: SHT_PROGBITS
+// CHECK-NEXT: Flags [
+// CHECK-NEXT: SHF_ALLOC
+// CHECK-NEXT: SHF_TLS
+// CHECK-NEXT: SHF_WRITE
+// CHECK-NEXT: ]
+// CHECK-NEXT: Address: 0x12000
+// CHECK-NEXT: Offset: 0x2000
+// CHECK-NEXT: Size: 4
+
+// CHECK: Name: .tbss
+// CHECK-NEXT: Type: SHT_NOBITS
+// CHECK-NEXT: Flags [
+// CHECK-NEXT: SHF_ALLOC
+// CHECK-NEXT: SHF_TLS
+// CHECK-NEXT: SHF_WRITE
+// CHECK-NEXT: ]
+// CHECK-NEXT: Address: 0x12010
+// CHECK-NEXT: Offset: 0x2004
+// CHECK-NEXT: Size: 16
+
+// CHECK: Name: .data
+// CHECK-NEXT: Type: SHT_PROGBITS
+// CHECK-NEXT: Flags [
+// CHECK-NEXT: SHF_ALLOC
+// CHECK-NEXT: SHF_WRITE
+// CHECK-NEXT: ]
+// CHECK-NEXT: Address: 0x12004
+// CHECK-NEXT: Offset: 0x2004
+// CHECK-NEXT: Size: 4
More information about the llvm-commits
mailing list