[PATCH] D106987: [ELF] Align the first section of a PT_TLS even if its type is SHT_NOBITS
Jessica Clarke via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 29 07:14:18 PDT 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcfaa5bf4ce62: [ELF] Align the first section of a PT_TLS even if its type is SHT_NOBITS (authored by jrtc27).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D106987/new/
https://reviews.llvm.org/D106987
Files:
lld/ELF/Writer.cpp
lld/test/ELF/linkerscript/tls-nobits-offset.s
lld/test/ELF/tls-nobits-offset.s
Index: lld/test/ELF/tls-nobits-offset.s
===================================================================
--- lld/test/ELF/tls-nobits-offset.s
+++ lld/test/ELF/tls-nobits-offset.s
@@ -7,13 +7,12 @@
## p_offset will be set to the sh_offset field of the section. Check we align
## sh_offset to sh_addr modulo p_align, so that p_vaddr=p_offset (mod
## p_align).
-## TODO: Currently we fail to ensure this, as shown by this test
# CHECK: Name Type Address Off Size ES Flg Lk Inf Al
-# CHECK: .tbss NOBITS 0000000000211000 000158 000001 00 WAT 0 0 4096
+# CHECK: .tbss NOBITS 0000000000211000 001000 000001 00 WAT 0 0 4096
# CHECK: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
-# CHECK: TLS 0x000158 0x0000000000211000 0x0000000000211000 0x000000 0x000001 R 0x1000
+# CHECK: TLS 0x001000 0x0000000000211000 0x0000000000211000 0x000000 0x000001 R 0x1000
# CHECK: 02 .tbss
Index: lld/test/ELF/linkerscript/tls-nobits-offset.s
===================================================================
--- lld/test/ELF/linkerscript/tls-nobits-offset.s
+++ lld/test/ELF/linkerscript/tls-nobits-offset.s
@@ -11,17 +11,16 @@
## p_offset will be set to the sh_offset field of the section. Check we align
## sh_offset to sh_addr modulo p_align, so that p_vaddr=p_offset (mod
## p_align).
-## TODO: Currently we fail to ensure this, as shown by this test
# CHECK: Name Type Address Off Size
# CHECK-NEXT: NULL 0000000000000000 000000 000000
# CHECK-NEXT: .text PROGBITS 0000000000000000 000190 000000
# CHECK-NEXT: .sec1 PROGBITS 0000000000000000 001000 000001
-# CHECK-NEXT: .tbss NOBITS 0000000000000400 001001 000001
+# CHECK-NEXT: .tbss NOBITS 0000000000000400 001400 000001
# CHECK: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
# CHECK-NEXT: LOAD 0x001000 0x0000000000000000 0x0000000000000000 0x000001 0x000001 R 0x1000
-# CHECK-NEXT: TLS 0x001001 0x0000000000000400 0x0000000000000400 0x000000 0x000001 R 0x400
+# CHECK-NEXT: TLS 0x001400 0x0000000000000400 0x0000000000000400 0x000000 0x000001 R 0x400
# CHECK: 00 .sec1 {{$}}
# CHECK: 01 .tbss {{$}}
Index: lld/ELF/Writer.cpp
===================================================================
--- lld/ELF/Writer.cpp
+++ lld/ELF/Writer.cpp
@@ -2597,9 +2597,10 @@
return alignTo(off, os->ptLoad->p_align, os->addr);
// File offsets are not significant for .bss sections other than the first one
- // in a PT_LOAD. By convention, we keep section offsets monotonically
+ // in a PT_LOAD/PT_TLS. By convention, we keep section offsets monotonically
// increasing rather than setting to zero.
- if (os->type == SHT_NOBITS)
+ if (os->type == SHT_NOBITS &&
+ (!Out::tlsPhdr || Out::tlsPhdr->firstSec != os))
return off;
// If the section is not in a PT_LOAD, we just have to align it.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106987.362766.patch
Type: text/x-patch
Size: 2949 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210729/4a6aee2f/attachment.bin>
More information about the llvm-commits
mailing list