x86-64: Skip protected check on symbol defined by linker
authorH.J. Lu <hjl.tools@gmail.com>
Wed, 27 Feb 2019 19:53:16 +0000 (11:53 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Wed, 27 Feb 2019 19:53:27 +0000 (11:53 -0800)
Skip symbol defined by linker when checking copy reloc on protected
symbol.

bfd/

PR ld/24276
* elf64-x86-64.c (elf_x86_64_check_relocs): Skip symbol defined
by linker when checking copy reloc on protected symbol.

ld/

PR ld/24276
* testsuite/ld-i386/i386.exp: Run PR ld/24276 test.
* testsuite/ld-x86-64/x86-64.exp: Likewise.
* testsuite/ld-i386/pr24276.dso: New file.
* testsuite/ld-i386/pr24276.warn: Likewise.
* testsuite/ld-x86-64/pr24276.dso: Likewise.
* testsuite/ld-x86-64/pr24276.warn: Likewise.

bfd/ChangeLog
bfd/elf64-x86-64.c
ld/ChangeLog
ld/testsuite/ld-i386/i386.exp
ld/testsuite/ld-i386/pr24276.dso [new file with mode: 0644]
ld/testsuite/ld-i386/pr24276.warn [new file with mode: 0644]
ld/testsuite/ld-x86-64/pr24276.dso [new file with mode: 0644]
ld/testsuite/ld-x86-64/pr24276.warn [new file with mode: 0644]
ld/testsuite/ld-x86-64/x86-64.exp

index e206629bd763f346a601e116ff527760b10baa97..f0aec1f655617debb7cef03e04a0b14674771360 100644 (file)
@@ -1,3 +1,9 @@
+2019-02-27  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/24276
+       * elf64-x86-64.c (elf_x86_64_check_relocs): Skip symbol defined
+       by linker when checking copy reloc on protected symbol.
+
 2019-02-24  Alan Modra  <amodra@gmail.com>
 
        PR 24144
index 6a4b366fddacae313e73e77e5eed0596d51d2a98..e193f44e93f17d4270b1e5da6a7ceb1cd5f1e9e5 100644 (file)
@@ -2238,6 +2238,8 @@ check_pic:
              bfd_boolean no_copyreloc_p
                = (info->nocopyreloc
                   || (h != NULL
+                      && !h->root.linker_def
+                      && !h->root.ldscript_def
                       && eh->def_protected
                       && elf_has_no_copy_on_protected (h->root.u.def.section->owner)));
              if ((sec->flags & SEC_ALLOC) != 0
index 0e00e41b920986a6edbdc60a96165eca35ae4800..cd368bd80c9ca94679b0f67ba391cc764c616b08 100644 (file)
@@ -1,3 +1,13 @@
+2019-02-27  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/24276
+       * testsuite/ld-i386/i386.exp: Run PR ld/24276 test.
+       * testsuite/ld-x86-64/x86-64.exp: Likewise.
+       * testsuite/ld-i386/pr24276.dso: New file.
+       * testsuite/ld-i386/pr24276.warn: Likewise.
+       * testsuite/ld-x86-64/pr24276.dso: Likewise.
+       * testsuite/ld-x86-64/pr24276.warn: Likewise.
+
 2019-02-20  Eric Tsai  <erictsai@cadence.com>
 
        * testsuite/ld-xtensa/call_overflow.d: New test definition.
index 5b90362cb0ce5457f8270202aa35ef8140215614..e51a4c30f623cabbf67206a1d9596466d9d51966 100644 (file)
@@ -804,6 +804,15 @@ if { [isnative]
            {{objdump {-dw} pr19319.dd}} \
            "pr19319" \
        ] \
+       [list \
+           "Build pr24276.so" \
+           "-shared -nostdlib -nostartfiles \
+            -Ltmpdir $srcdir/$subdir/pr24276.dso" \
+           "-Wa,-mx86-used-note=yes" \
+           { pr19319b.S } \
+           {{warning_output pr24276.warn}} \
+           "pr24276.so" \
+       ] \
        [list \
            "Build property 1" \
            "" \
diff --git a/ld/testsuite/ld-i386/pr24276.dso b/ld/testsuite/ld-i386/pr24276.dso
new file mode 100644 (file)
index 0000000..9add115
--- /dev/null
@@ -0,0 +1,9 @@
+INPUT(pr19319.so)
+SECTIONS {
+  my_section : {
+    __start_my_section = .;
+    *(my_section);
+    __stop_my_section = .;
+
+  }
+}
diff --git a/ld/testsuite/ld-i386/pr24276.warn b/ld/testsuite/ld-i386/pr24276.warn
new file mode 100644 (file)
index 0000000..5fcfa34
--- /dev/null
@@ -0,0 +1 @@
+.*contains output sections.*
diff --git a/ld/testsuite/ld-x86-64/pr24276.dso b/ld/testsuite/ld-x86-64/pr24276.dso
new file mode 100644 (file)
index 0000000..9add115
--- /dev/null
@@ -0,0 +1,9 @@
+INPUT(pr19319.so)
+SECTIONS {
+  my_section : {
+    __start_my_section = .;
+    *(my_section);
+    __stop_my_section = .;
+
+  }
+}
diff --git a/ld/testsuite/ld-x86-64/pr24276.warn b/ld/testsuite/ld-x86-64/pr24276.warn
new file mode 100644 (file)
index 0000000..5fcfa34
--- /dev/null
@@ -0,0 +1 @@
+.*contains output sections.*
index 5eb556515faf395cc7b4369d274a73b9f458ccd8..b03aaced91f8bb6d7ac14ea6de3aa8d7e61821d7 100644 (file)
@@ -940,6 +940,15 @@ if { [isnative] && [which $CC] != 0 } {
            {{objdump {-dw} pr19319.dd}} \
            "pr19319" \
        ] \
+       [list \
+           "Build pr24276.so" \
+           "-shared -nostdlib -nostartfiles \
+            -Ltmpdir $srcdir/$subdir/pr24276.dso" \
+           "-Wa,-mx86-used-note=yes" \
+           { pr19319b.S } \
+           {{warning_output pr24276.warn}} \
+           "pr24276.so" \
+       ] \
        [list \
            "Build property 1" \
            "" \