Handle relocation against protected function for -Bsymbolic
authorH.J. Lu <hjl.tools@gmail.com>
Tue, 20 Mar 2012 18:16:38 +0000 (18:16 +0000)
committerH.J. Lu <hjl.tools@gmail.com>
Tue, 20 Mar 2012 18:16:38 +0000 (18:16 +0000)
bfd/

2012-03-20  H.J. Lu  <hongjiu.lu@intel.com>

PR ld/13880
* elf32-i386.c (elf_i386_relocate_section): Don't issue an error
for R_386_GOTOFF relocation against protected function if
SYMBOLIC_BIND is true.

* elf64-x86-64.c (elf_x86_64_relocate_section): Don't issue an
error for R_X86_64_GOTOFF64 relocation against protected function
when building executable or SYMBOLIC_BIND is true.

ld/testsuite/

2012-03-20  H.J. Lu  <hongjiu.lu@intel.com>

PR ld/13880
* ld-i386/i386.exp: Run protected4 and protected5.
* ld-x86-64/x86-64.exp: Likewise.

* ld-i386/protected4.d: New.
* ld-i386/protected4.s: Likewise.
* ld-i386/protected5.d: Likewise.
* ld-i386/protected5.s: Likewise.
* ld-x86-64/protected4.d: Likewise.
* ld-x86-64/protected4.s: Likewise.
* ld-x86-64/protected5.d: Likewise.
* ld-x86-64/protected5.s: Likewise.

14 files changed:
bfd/ChangeLog
bfd/elf32-i386.c
bfd/elf64-x86-64.c
ld/testsuite/ChangeLog
ld/testsuite/ld-i386/i386.exp
ld/testsuite/ld-i386/protected4.d [new file with mode: 0644]
ld/testsuite/ld-i386/protected4.s [new file with mode: 0644]
ld/testsuite/ld-i386/protected5.d [new file with mode: 0644]
ld/testsuite/ld-i386/protected5.s [new file with mode: 0644]
ld/testsuite/ld-x86-64/protected4.d [new file with mode: 0644]
ld/testsuite/ld-x86-64/protected4.s [new file with mode: 0644]
ld/testsuite/ld-x86-64/protected5.d [new file with mode: 0644]
ld/testsuite/ld-x86-64/protected5.s [new file with mode: 0644]
ld/testsuite/ld-x86-64/x86-64.exp

index b9849f8f50dd74138205e2aac17618c7ab5643f8..735a0ba51d50de83b72f44a6657dbec18ef7ecec 100644 (file)
@@ -1,3 +1,14 @@
+2012-03-20  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/13880
+       * elf32-i386.c (elf_i386_relocate_section): Don't issue an error
+       for R_386_GOTOFF relocation against protected function if
+       SYMBOLIC_BIND is true.
+
+       * elf64-x86-64.c (elf_x86_64_relocate_section): Don't issue an
+       error for R_X86_64_GOTOFF64 relocation against protected function
+       when building executable or SYMBOLIC_BIND is true.
+
 2012-03-16  Roland McGrath  <mcgrathr@google.com>
 
        * config.bfd: Handle x86_64-*-nacl*.
index 4ae21664f6a11786f8f245a31348a4467becd4a6..f35e3c22a99f9afe61292a1d11d3a593bb078dc2 100644 (file)
@@ -3503,6 +3503,7 @@ elf_i386_relocate_section (bfd *output_bfd,
                  return FALSE;
                }
              else if (!info->executable
+                      && !SYMBOLIC_BIND (info, h)
                       && h->type == STT_FUNC
                       && ELF_ST_VISIBILITY (h->other) == STV_PROTECTED)
                {
index f2f803a54b80d2f093b40be4c4fd6f55a4c88e56..cc5ee42b81cfb91eae0139c47df8937958675672 100644 (file)
@@ -3464,8 +3464,9 @@ elf_x86_64_relocate_section (bfd *output_bfd,
          /* Check to make sure it isn't a protected function symbol
             for shared library since it may not be local when used
             as function address.  */
-         if (info->shared
+         if (!info->executable
              && h
+             && !SYMBOLIC_BIND (info, h)
              && h->def_regular
              && h->type == STT_FUNC
              && ELF_ST_VISIBILITY (h->other) == STV_PROTECTED)
index 1bcf098d909f3cfc6c52d71159a2582accd1b3c3..ac06f535b80d616bdb31cb328c4023e806752d9c 100644 (file)
@@ -1,3 +1,18 @@
+2012-03-20  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/13880
+       * ld-i386/i386.exp: Run protected4 and protected5.
+       * ld-x86-64/x86-64.exp: Likewise.
+
+       * ld-i386/protected4.d: New.
+       * ld-i386/protected4.s: Likewise.
+       * ld-i386/protected5.d: Likewise.
+       * ld-i386/protected5.s: Likewise.
+       * ld-x86-64/protected4.d: Likewise.
+       * ld-x86-64/protected4.s: Likewise.
+       * ld-x86-64/protected5.d: Likewise.
+       * ld-x86-64/protected5.s: Likewise.
+
 2012-03-19  Andreas Schwab  <schwab@linux-m68k.org>
 
        * ld-m68k/m68k.exp ("TLS indirect symbol use"): Pass
index 17279224006487b7cdb10549989fb5ff10bd7ad5..ff9db9829e42c8db48ac148d152b58ab32927169 100644 (file)
@@ -194,6 +194,8 @@ run_dump_test "hidden3"
 run_dump_test "protected1"
 run_dump_test "protected2"
 run_dump_test "protected3"
+run_dump_test "protected4"
+run_dump_test "protected5"
 run_dump_test "tlspie1"
 run_dump_test "tlspie2"
 run_dump_test "nogot1"
diff --git a/ld/testsuite/ld-i386/protected4.d b/ld/testsuite/ld-i386/protected4.d
new file mode 100644 (file)
index 0000000..f16f0c0
--- /dev/null
@@ -0,0 +1,5 @@
+#as: --32
+#ld: -shared -Bsymbolic -melf_i386
+#readelf: -r
+
+There are no relocations in this file.
diff --git a/ld/testsuite/ld-i386/protected4.s b/ld/testsuite/ld-i386/protected4.s
new file mode 100644 (file)
index 0000000..66f2a56
--- /dev/null
@@ -0,0 +1,12 @@
+       .text
+       .protected      foo
+       .globl foo
+       .type   foo, @function
+foo:
+       ret
+       .size   foo, .-foo
+       .globl bar
+       .type   bar, @function
+bar:
+       movl    foo@GOTOFF(%ecx), %eax
+       .size   bar, .-bar
diff --git a/ld/testsuite/ld-i386/protected5.d b/ld/testsuite/ld-i386/protected5.d
new file mode 100644 (file)
index 0000000..89e2159
--- /dev/null
@@ -0,0 +1,5 @@
+#as: --32
+#ld: -pie -melf_i386
+#readelf: -r
+
+There are no relocations in this file.
diff --git a/ld/testsuite/ld-i386/protected5.s b/ld/testsuite/ld-i386/protected5.s
new file mode 100644 (file)
index 0000000..fc218f2
--- /dev/null
@@ -0,0 +1,12 @@
+       .text
+       .protected      foo
+       .globl foo
+       .type   foo, @function
+foo:
+       ret
+       .size   foo, .-foo
+       .globl _start
+       .type   _start, @function
+_start:
+       movl    foo@GOTOFF(%ecx), %eax
+       .size   _start, .-_start
diff --git a/ld/testsuite/ld-x86-64/protected4.d b/ld/testsuite/ld-x86-64/protected4.d
new file mode 100644 (file)
index 0000000..a8a8980
--- /dev/null
@@ -0,0 +1,5 @@
+#as: --64
+#ld: -shared -Bsymbolic -melf_x86_64
+#readelf: -r
+
+There are no relocations in this file.
diff --git a/ld/testsuite/ld-x86-64/protected4.s b/ld/testsuite/ld-x86-64/protected4.s
new file mode 100644 (file)
index 0000000..c6e41ec
--- /dev/null
@@ -0,0 +1,12 @@
+       .text
+       .protected      foo
+       .globl foo
+       .type   foo, @function
+foo:
+       ret
+       .size   foo, .-foo
+       .globl bar
+       .type   bar, @function
+bar:
+       movabsq $foo@GOTOFF, %rax
+       .size   bar, .-bar
diff --git a/ld/testsuite/ld-x86-64/protected5.d b/ld/testsuite/ld-x86-64/protected5.d
new file mode 100644 (file)
index 0000000..afe172a
--- /dev/null
@@ -0,0 +1,5 @@
+#as: --64
+#ld: -pie -melf_x86_64
+#readelf: -r
+
+There are no relocations in this file.
diff --git a/ld/testsuite/ld-x86-64/protected5.s b/ld/testsuite/ld-x86-64/protected5.s
new file mode 100644 (file)
index 0000000..8e14138
--- /dev/null
@@ -0,0 +1,12 @@
+       .text
+       .protected      foo
+       .globl foo
+       .type   foo, @function
+foo:
+       ret
+       .size   foo, .-foo
+       .globl _start
+       .type   _start, @function
+_start:
+       movabsq $foo@GOTOFF, %rax
+       .size   _start, .-_start
index f713ca51a1b32564cab9b3a6bba4d5c2ed7683bc..c2582518537989f4734153f57484b4043abb2e4e 100644 (file)
@@ -158,6 +158,8 @@ run_dump_test "protected2"
 run_dump_test "protected2-l1om"
 run_dump_test "protected3"
 run_dump_test "protected3-l1om"
+run_dump_test "protected4"
+run_dump_test "protected5"
 run_dump_test "tlsle1"
 run_dump_test "tlspie1"
 run_dump_test "unique1"