elf: Correct DT_TEXTREL warning in PDE
authorH.J. Lu <hjl.tools@gmail.com>
Sat, 19 Jun 2021 23:33:24 +0000 (16:33 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Sat, 19 Jun 2021 23:33:35 +0000 (16:33 -0700)
Change

ld: warning: creating DT_TEXTREL in a PIE

to

ld: warning: creating DT_TEXTREL in a PDE

on PDE.

bfd/

* elflink.c (bfd_elf_final_link): Correct DT_TEXTREL warning in
PDE.

ld/

* testsuite/ld-x86-64/textrel-1.err: New file.
* testsuite/ld-x86-64/textrel-1a.s: Likewise.
* testsuite/ld-x86-64/textrel-1b.s: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Run textrel-1 tests.

bfd/ChangeLog
bfd/elflink.c
ld/ChangeLog
ld/testsuite/ld-x86-64/textrel-1.err [new file with mode: 0644]
ld/testsuite/ld-x86-64/textrel-1a.s [new file with mode: 0644]
ld/testsuite/ld-x86-64/textrel-1b.s [new file with mode: 0644]
ld/testsuite/ld-x86-64/x86-64.exp

index 29e41a31a9eace735a2893f2d9ffb9e7ee440506..5211e98e111c39e215aaa340d6bea99a99f10a78 100644 (file)
@@ -1,3 +1,8 @@
+2021-06-19  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * elflink.c (bfd_elf_final_link): Correct DT_TEXTREL warning in
+       PDE.
+
 2021-06-18  H.J. Lu  <hongjiu.lu@intel.com>
 
        * elf-properties.c (_bfd_elf_parse_gnu_properties): Handle
index c9a6e78be798ba7677ca8c3d0a5f8cbe10c1c8f1..9a05208253c228f72d11b22401c002237d960e31 100644 (file)
@@ -13138,6 +13138,9 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
                  else if (bfd_link_dll (info))
                    info->callbacks->einfo
                      (_("%P: warning: creating DT_TEXTREL in a shared object\n"));
+                 else if (bfd_link_pde (info))
+                   info->callbacks->einfo
+                     (_("%P: warning: creating DT_TEXTREL in a PDE\n"));
                  else
                    info->callbacks->einfo
                      (_("%P: warning: creating DT_TEXTREL in a PIE\n"));
index c84992d7633e3030122478f1f8f484066f622773..36f8d4b5268f26767b728a80571378a76af181d0 100644 (file)
@@ -1,3 +1,10 @@
+2021-06-19  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * testsuite/ld-x86-64/textrel-1.err: New file.
+       * testsuite/ld-x86-64/textrel-1a.s: Likewise.
+       * testsuite/ld-x86-64/textrel-1b.s: Likewise.
+       * testsuite/ld-x86-64/x86-64.exp: Run textrel-1 tests.
+
 2021-06-18  H.J. Lu  <hongjiu.lu@intel.com>
 
        * testsuite/ld-elf/property-and-1.d: Skip am33_2.0, hppa-hpux
diff --git a/ld/testsuite/ld-x86-64/textrel-1.err b/ld/testsuite/ld-x86-64/textrel-1.err
new file mode 100644 (file)
index 0000000..222c7a3
--- /dev/null
@@ -0,0 +1,4 @@
+#...
+.*textrel-1b.o: warning: relocation against `foo' in read-only section `.rodata'
+.*: warning: creating DT_TEXTREL in a PDE
+#...
diff --git a/ld/testsuite/ld-x86-64/textrel-1a.s b/ld/testsuite/ld-x86-64/textrel-1a.s
new file mode 100644 (file)
index 0000000..6b486a9
--- /dev/null
@@ -0,0 +1,9 @@
+       .text
+       .globl  foo
+       .data
+       .align 4
+       .type   foo, @object
+       .size   foo, 4
+foo:
+       .long   4
+       .section        .note.GNU-stack,"",@progbits
diff --git a/ld/testsuite/ld-x86-64/textrel-1b.s b/ld/testsuite/ld-x86-64/textrel-1b.s
new file mode 100644 (file)
index 0000000..8f125e4
--- /dev/null
@@ -0,0 +1,15 @@
+       .text
+       .p2align 4
+       .globl  _start
+       .type   _start, @function
+_start:
+       ret
+       .size   _start, .-_start
+       .globl  ptr
+       .section        .rodata
+       .align 8
+       .type   ptr, @object
+       .size   ptr, 8
+ptr:
+       .quad   foo
+       .section        .note.GNU-stack,"",@progbits
index 21a4824e3d19c8405bdb4f332a7564035f8c2d59..3bf62504cf963b8e3a9f04cfcd87f842cb8db10f 100644 (file)
@@ -231,6 +231,11 @@ set x86_64tests {
      "" ""
      { pr27590a.obj.bz2 pr27590b.obj.bz2 }
      {{readelf -SW pr27590.rd}} "pr27590.o"}
+    {"Build textrel-1.so" "-melf_x86_64 -shared" ""
+     "--64" { textrel-1a.s } {} "textrel-1.so"}
+    {"Build textrel-1" "-no-pie -melf_x86_64 -z nocopyreloc"
+     "tmpdir/textrel-1.so"
+     "--64" { textrel-1b.s } {{ld "textrel-1.err"}} "textrel-1"}
 }
 
 run_ld_link_tests $x86_64tests
This page took 0.037188 seconds and 4 git commands to generate.