[lld] r326503 - Set DF_TEXTREL to executables that need text relocations.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 1 14:56:52 PST 2018


Author: ruiu
Date: Thu Mar  1 14:56:52 2018
New Revision: 326503

URL: http://llvm.org/viewvc/llvm-project?rev=326503&view=rev
Log:
Set DF_TEXTREL to executables that need text relocations.

Summary:
If an executable needs text relocations, it should be marked as such so
that the loader can prepare for text relocations. We currently create a
dummy segment with DT_TEXTREL for that purpose.

Generic ABI as of 2000 [1] mentioned that "Its [DT_TEXTREL's] use
has been superseded by the DF_TEXTREL flag". However, it's actually not
superseded even after 18 years. OpenBSD and musl recognize only DT_TEXTREL.
So we still need to set both.

[1] http://www.sco.com/developers/gabi/2000-07-17/ch5.dynamic.html

Reviewers: rafael

Subscribers: emaste, llvm-commits, arichardson

Differential Revision: https://reviews.llvm.org/D43920

Modified:
    lld/trunk/ELF/SyntheticSections.cpp
    lld/trunk/test/ELF/ztext-text-notext.s

Modified: lld/trunk/ELF/SyntheticSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.cpp?rev=326503&r1=326502&r2=326503&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.cpp (original)
+++ lld/trunk/ELF/SyntheticSections.cpp Thu Mar  1 14:56:52 2018
@@ -1046,6 +1046,8 @@ template <class ELFT> void DynamicSectio
     DtFlags |= DF_ORIGIN;
     DtFlags1 |= DF_1_ORIGIN;
   }
+  if (!Config->ZText)
+    DtFlags |= DF_TEXTREL;
 
   if (DtFlags)
     addInt(DT_FLAGS, DtFlags);

Modified: lld/trunk/test/ELF/ztext-text-notext.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/ztext-text-notext.s?rev=326503&r1=326502&r2=326503&view=diff
==============================================================================
--- lld/trunk/test/ELF/ztext-text-notext.s (original)
+++ lld/trunk/test/ELF/ztext-text-notext.s Thu Mar  1 14:56:52 2018
@@ -18,8 +18,10 @@
 # CHECK-NEXT:      0x1010 R_X86_64_PC64 zed 0x0
 # CHECK-NEXT:    }
 # CHECK-NEXT:  ]
+
 # CHECK: DynamicSection [
-# CHECK: 0x0000000000000016 TEXTREL 0x0
+# CHECK:   FLAGS TEXTREL
+# CHECK:   TEXTREL 0x0
 
 # STATIC:      Relocations [
 # STATIC-NEXT:    Section {{.*}} .rela.dyn {
@@ -27,8 +29,10 @@
 # STATIC-NEXT:      0x201010 R_X86_64_PC64 zed 0x0
 # STATIC-NEXT:    }
 # STATIC-NEXT:  ]
+
 # STATIC: DynamicSection [
-# STATIC: 0x0000000000000016 TEXTREL 0x0
+# STATIC:   FLAGS TEXTREL
+# STATIC:   TEXTREL 0x0
 
 foo:
 .quad foo




More information about the llvm-commits mailing list