+2014-08-26 Jiong Wang <jiong.wang@arm.com>
+
+ * elfnn-aarch64.c (elfNN_aarch64_check_relocs): Initialize non_got_ref
+ properly for MOVW_G0/1/2_NC and MOVW_G3. Reject them when linking
+ shared library.
+ (elfNN_aarch64_gc_sweep_hook): Add check on these relocs.
+
2014-08-26 Nick Clifton <nickc@redhat.com>
* config.bfd: Fix typo in or1knd selection.
}
break;
- case BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL:
- case BFD_RELOC_AARCH64_ADR_HI21_PCREL:
- case BFD_RELOC_AARCH64_ADR_LO21_PCREL:
- if (h != NULL && info->executable)
- {
- if (h->plt.refcount > 0)
- h->plt.refcount -= 1;
- }
- break;
-
case BFD_RELOC_AARCH64_CALL26:
case BFD_RELOC_AARCH64_JUMP26:
/* If this is a local symbol then we resolve it
h->plt.refcount -= 1;
break;
+ case BFD_RELOC_AARCH64_MOVW_G0_NC:
+ case BFD_RELOC_AARCH64_MOVW_G1_NC:
+ case BFD_RELOC_AARCH64_MOVW_G2_NC:
+ case BFD_RELOC_AARCH64_MOVW_G3:
+ case BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL:
+ case BFD_RELOC_AARCH64_ADR_HI21_PCREL:
+ case BFD_RELOC_AARCH64_ADR_LO21_PCREL:
case BFD_RELOC_AARCH64_NN:
if (h != NULL && info->executable)
{
break;
}
+ case BFD_RELOC_AARCH64_MOVW_G0_NC:
+ case BFD_RELOC_AARCH64_MOVW_G1_NC:
+ case BFD_RELOC_AARCH64_MOVW_G2_NC:
+ case BFD_RELOC_AARCH64_MOVW_G3:
+ if (info->shared)
+ {
+ int howto_index = bfd_r_type - BFD_RELOC_AARCH64_RELOC_START;
+ (*_bfd_error_handler)
+ (_("%B: relocation %s against `%s' can not be used when making "
+ "a shared object; recompile with -fPIC"),
+ abfd, elfNN_aarch64_howto_table[howto_index].name,
+ (h) ? h->root.root.string : "a local symbol");
+ bfd_set_error (bfd_error_bad_value);
+ return FALSE;
+ }
+
case BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL:
case BFD_RELOC_AARCH64_ADR_HI21_PCREL:
case BFD_RELOC_AARCH64_ADR_LO21_PCREL:
+2014-08-26 Jiong Wang <jiong.wang@arm.com>
+
+ * ld-aarch64/copy-relocs-so.s: New test file.
+ * ld-aarch64/copy-relocs-exe.s: Likewise.
+ * ld-aarch64/copy-relocs.d: New expectation file.
+ * ld-aarch64/emit-relocs-264-bad.d: New test file.
+ * ld-aarch64/emit-relocs-266-bad.d: Likewise.
+ * ld-aarch64/emit-relocs-268-bad.d: Likewise.
+ * ld-aarch64/emit-relocs-269-bad.d: Likewise.
+ * ld-aarch64/aarch64-elf.exp: Run new added test.
+
2014-08-26 Nick Clifton <nickc@redhat.com>
* ld-aarch64/eh-frame-foo.s: Use 8-byte offset for X30.
run_dump_test "emit-relocs-262"
run_dump_test "emit-relocs-263"
run_dump_test "emit-relocs-264"
+run_dump_test "emit-relocs-264-bad"
run_dump_test "emit-relocs-265"
run_dump_test "emit-relocs-266"
+run_dump_test "emit-relocs-266-bad"
run_dump_test "emit-relocs-267"
run_dump_test "emit-relocs-268"
+run_dump_test "emit-relocs-268-bad"
run_dump_test "emit-relocs-269"
+run_dump_test "emit-relocs-269-bad"
run_dump_test "emit-relocs-270"
run_dump_test "emit-relocs-270-bad"
run_dump_test "emit-relocs-271"
run_dump_test "ifunc-22"
run_dump_test "relasz"
+
+set aarch64elflinktests {
+ {"ld-aarch64/so with global symbol" "-shared" "" "" {copy-reloc-so.s}
+ {} "copy-reloc-so.so"}
+ {"ld-aarch64/exe with copy relocation" "-e0 tmpdir/copy-reloc-so.so" "" ""
+ {copy-reloc-exe.s} {{objdump -R copy-reloc.d}} "copy-reloc"}
+}
+
+run_ld_link_tests $aarch64elflinktests
--- /dev/null
+ .text
+ .global main
+main:
+ movz x0,:abs_g0_nc:global_a
+ movk x0,:abs_g1_nc:global_a
+ movk x0,:abs_g2_nc:global_a
+ movk x0,:abs_g3:global_a
--- /dev/null
+ .global global_a
+ .type global_a, %object
+ .size global_a, 4
+ .data
+global_a:
+ .word 0xcafedead
--- /dev/null
+.*
+DYNAMIC RELOCATION RECORDS
+OFFSET.*TYPE.*VALUE.*
+.*R_AARCH64_COPY.*global_a
--- /dev/null
+#source: emit-relocs-264.s
+#ld: -T relocs.ld --defsym tempy=0x11000 --defsym tempy2=0x45000 --defsym tempy3=0x1234 -e0 -shared
+#error: .*relocation R_AARCH64_MOVW_UABS_G0_NC.*can not.*shared object.*fPIC
--- /dev/null
+#source: emit-relocs-266.s
+#ld: -T relocs.ld --defsym tempy=0x11000 --defsym tempy2=0x45000 --defsym tempy3=0x1234 -e0 -shared
+#error: .*relocation R_AARCH64_MOVW_UABS_G1_NC.*can not.*shared object.*fPIC
--- /dev/null
+#source: emit-relocs-268.s
+#ld: -T relocs.ld --defsym tempy=0x11000 --defsym tempy2=0x45000 --defsym tempy3=0x1234 -e0 -shared
+#error: .*relocation R_AARCH64_MOVW_UABS_G2_NC.*can not.*shared object.*fPIC
--- /dev/null
+#source: emit-relocs-269.s
+#ld: -T relocs.ld --defsym tempy=0x11000 --defsym tempy2=0x45000 --defsym tempy3=0x1234 -e0 -shared
+#error: .*relocation R_AARCH64_MOVW_UABS_G3.*can not.*shared object.*fPIC