[PATCH] D43920: Set DF_TEXTREL instead of creating an empty DT_TEXTREL.
Rui Ueyama via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 28 16:42:15 PST 2018
ruiu created this revision.
ruiu added a reviewer: rafael.
Herald added subscribers: arichardson, emaste.
Generic ABI as of 2000 [1] mentioned that "Its [DT_TEXTREL's] use
has been superseded by the DF_TEXTREL flag". We currently create only
DT_TEXTREL and don't set the DF_TEXTREL flag.
This patch is to let the linker to set the flag instead of creating
a DT_TEXTREL marker segment.
With this patch, lld no longer emits DT_TEXTREL. I believe that's not
an issue because it is a very old option and text relocation is rare.
If you want to keep it, we can set both DT_TEXTREL and DF_TEXTREL though.
But I'm not comfortable with supporting only the old way.
[1] http://www.sco.com/developers/gabi/2000-07-17/ch5.dynamic.html
https://reviews.llvm.org/D43920
Files:
lld/ELF/SyntheticSections.cpp
lld/test/ELF/Inputs/ztext-text-notext.s
lld/test/ELF/Inputs/ztext.s
lld/test/ELF/ztext-text-notext.s
lld/test/ELF/ztext.s
Index: lld/test/ELF/ztext.s
===================================================================
--- lld/test/ELF/ztext.s
+++ lld/test/ELF/ztext.s
@@ -1,13 +1,13 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
-# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/ztext-text-notext.s -o %t2.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/ztext.s -o %t2.o
# RUN: ld.lld %t2.o -o %t2.so -shared
# RUN: ld.lld -z notext %t.o %t2.so -o %t -shared
-# RUN: llvm-readobj -dynamic-table -r %t | FileCheck %s
+# RUN: llvm-readobj -dynamic-table -r %t | FileCheck %s
# RUN: ld.lld -z notext %t.o %t2.so -o %t2 -pie
-# RUN: llvm-readobj -dynamic-table -r %t2 | FileCheck %s
+# RUN: llvm-readobj -dynamic-table -r %t2 | FileCheck %s
# RUN: ld.lld -z notext %t.o %t2.so -o %t3
-# RUN: llvm-readobj -dynamic-table -r %t3 | FileCheck --check-prefix=STATIC %s
+# RUN: llvm-readobj -dynamic-table -r %t3 | FileCheck --check-prefix=STATIC %s
# If the preference is to have text relocations, don't create plt of copy relocations.
@@ -19,16 +19,16 @@
# CHECK-NEXT: }
# CHECK-NEXT: ]
# CHECK: DynamicSection [
-# CHECK: 0x0000000000000016 TEXTREL 0x0
+# CHECK: FLAGS TEXTREL
# STATIC: Relocations [
# STATIC-NEXT: Section {{.*}} .rela.dyn {
# STATIC-NEXT: 0x201008 R_X86_64_64 bar 0x0
# STATIC-NEXT: 0x201010 R_X86_64_PC64 zed 0x0
# STATIC-NEXT: }
# STATIC-NEXT: ]
# STATIC: DynamicSection [
-# STATIC: 0x0000000000000016 TEXTREL 0x0
+# STATIC: FLAGS TEXTREL
foo:
.quad foo
Index: lld/test/ELF/Inputs/ztext-text-notext.s
===================================================================
--- /dev/null
+++ lld/test/ELF/Inputs/ztext-text-notext.s
@@ -1,10 +0,0 @@
- .global bar
- .type bar, @object
- .size bar, 8
-bar:
- .quad 0
-
- .global zed
- .type zed, @function
-zed:
- nop
Index: lld/ELF/SyntheticSections.cpp
===================================================================
--- lld/ELF/SyntheticSections.cpp
+++ lld/ELF/SyntheticSections.cpp
@@ -1046,6 +1046,8 @@
DtFlags |= DF_ORIGIN;
DtFlags1 |= DF_1_ORIGIN;
}
+ if (!Config->ZText)
+ DtFlags |= DF_TEXTREL;
if (DtFlags)
addInt(DT_FLAGS, DtFlags);
@@ -1108,8 +1110,6 @@
addInt(DT_SYMENT, sizeof(Elf_Sym));
addInSec(DT_STRTAB, InX::DynStrTab);
addInt(DT_STRSZ, InX::DynStrTab->getSize());
- if (!Config->ZText)
- addInt(DT_TEXTREL, 0);
if (InX::GnuHashTab)
addInSec(DT_GNU_HASH, InX::GnuHashTab);
if (InX::HashTab)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43920.136430.patch
Type: text/x-patch
Size: 2576 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180301/728656dd/attachment.bin>
More information about the llvm-commits
mailing list