-*- text -*-
+* New command line option --reloc-section-sym=[all|internal|none]
+ controls whether relocations referencing local binding symbols are adjusted
+ to use section symbols.
+
* The aarch64 extensions TME and MPAMv2_VID have never been implemented in any
products. Arm has withdrawn them from the architecture. The assembler will
now warn if instructions or system registers from either extension are
DEFAULT_SFRAME ? "yes" : "no");
fprintf (stream, _("\
--gsframe-<N> generate SFrame version <N> information. 3 == <N>\n"));
+ fprintf (stream, _("\
+ --reloc-section-sym=[all|internal|none]\n\
+ adjust eligible relocations to use section symbols\n\
+ (default: all)\n"));
# if defined (TARGET_USE_SCFI) && defined (TARGET_USE_GINSN)
fprintf (stream, _("\
--scfi=experimental Synthesize DWARF CFI for hand-written asm\n\
OPTION_SFRAME_3,
OPTION_SCFI,
OPTION_INFO,
- OPTION_NOINFO
+ OPTION_NOINFO,
+ OPTION_RELOC_SECTION_SYM
/* When you add options here, check that they do
not collide with OPTION_MD_BASE. See as.h. */
};
,{"generate-missing-build-notes", required_argument, NULL, OPTION_ELF_BUILD_NOTES}
,{"gsframe", optional_argument, NULL, OPTION_SFRAME}
,{"gsframe-3", no_argument, NULL, OPTION_SFRAME_3}
+ ,{"reloc-section-sym", required_argument, NULL, OPTION_RELOC_SECTION_SYM}
# if defined (TARGET_USE_SCFI) && defined (TARGET_USE_GINSN)
,{"scfi", required_argument, NULL, OPTION_SCFI}
# endif
flag_sectname_subst = 1;
break;
+ case OPTION_RELOC_SECTION_SYM:
+ if (strcasecmp (optarg, "all") == 0)
+ flag_reloc_section_sym = reloc_section_sym_all;
+ else if (strcasecmp (optarg, "internal") == 0)
+ flag_reloc_section_sym = reloc_section_sym_internal;
+ else if (strcasecmp (optarg, "none") == 0)
+ flag_reloc_section_sym = reloc_section_sym_none;
+ else
+ as_fatal (_("Invalid --reloc-section-sym= option: `%s'"),
+ optarg);
+ break;
+
case OPTION_ELF_BUILD_NOTES:
if (strcasecmp (optarg, "no") == 0)
flag_generate_build_notes = false;
};
COMMON enum multibyte_input_handling multibyte_handling;
+/* Controls whether relocations referencing local symbols are converted
+ to use section symbols. */
+enum reloc_section_sym_type
+{
+ reloc_section_sym_all = 0,
+ reloc_section_sym_internal,
+ reloc_section_sym_none
+};
+COMMON enum reloc_section_sym_type flag_reloc_section_sym;
+
/* TRUE if we should produce a listing. */
extern int listing;
[@b{--multibyte-handling=[allow|warn|warn-sym-only]}]
[@b{--no-pad-sections}]
[@b{-o} @var{objfile}] [@b{-R}]
+ [@b{--reloc-section-sym=[all|internal|none]}]
[@b{--scfi=experimental}]
[@b{--sectname-subst}]
[@b{--size-check=[error|warning]}]
both the assembler and the linker.
@ifset ELF
+@item --reloc-section-sym=all
+@itemx --reloc-section-sym=internal
+@itemx --reloc-section-sym=none
+Control whether relocations referencing local binding symbols are adjusted to
+use section symbols instead. With @code{all} (the default), relocations
+against all eligible local binding symbols are converted. With
+@code{internal}, only relocations against internal labels (symbols matching the
+@code{.L} prefix) are converted. With @code{none}, no such conversions are
+performed.
+
@item --scfi=experimental
This option controls whether the assembler should synthesize CFI for
hand-written input. If the input already contains some synthesizable CFI
rx-*-* { }
loongarch*-*-* { }
default {
- # The next test can fail if the target does not convert fixups
+ # The following tests can fail if the target does not convert fixups
# against ordinary symbols into relocations against section symbols.
- # This is usually revealed by the error message:
- # symbol `sym' required but not present
setup_xfail "m681*-*-*" "m68hc*-*-*" "xgate-*-*" "vax-*-*" "avr-*-*"
run_dump_test redef
run_dump_test equ-reloc
+ setup_xfail "m681*-*-*" "m68hc*-*-*" "xgate-*-*" "vax-*-*" "avr-*-*"
+ run_dump_test "reloc-section-sym-all"
+ setup_xfail "m681*-*-*" "m68hc*-*-*" "xgate-*-*" "avr-*-*"
+ run_dump_test "reloc-section-sym-internal"
}
}
+ run_dump_test "reloc-section-sym-none"
run_dump_test "pseudo"
run_dump_test "text-prev" $dump_opts
run_dump_test "text-subsect" $dump_opts
--- /dev/null
+#source: reloc-section-sym.s
+#as: --reloc-section-sym=all
+#objdump: -rsj .data
+#name: reloc-section-sym=all
+
+.*: +file format .*
+
+RELOCATION RECORDS FOR \[\.data\]:
+OFFSET +TYPE +VALUE
+0*0 [^ ]+ +\.bss.*
+0*4 [^ ]+ +\.bss.*
+#pass
--- /dev/null
+#source: reloc-section-sym.s
+#as: --reloc-section-sym=internal
+#objdump: -rsj .data
+#name: reloc-section-sym=internal
+
+.*: +file format .*
+
+RELOCATION RECORDS FOR \[\.data\]:
+OFFSET +TYPE +VALUE
+0*0 [^ ]+ +local.*
+0*4 [^ ]+ +\.bss.*
+#pass
--- /dev/null
+#source: reloc-section-sym.s
+#as: --reloc-section-sym=none
+#objdump: -rsj .data
+#name: reloc-section-sym=none
+
+.*: +file format .*
+
+RELOCATION RECORDS FOR \[\.data\]:
+OFFSET +TYPE +VALUE
+0*0 [^ ]+ +local.*
+0*4 [^ ]+ +\.Ltemp.*
+#pass
--- /dev/null
+ .section .bss
+local:
+ .zero 1
+.Ltemp:
+ .zero 1
+
+ .data
+ .long local + 16
+ .long .Ltemp + 16
--- /dev/null
+#source: reloc-section-sym.s
+#as: --reloc-section-sym=all
+#objdump: -rsj .data -j .text1
+#name: reloc-section-sym=all
+
+.*: file format .*
+
+RELOCATION RECORDS FOR \[\.data\]:
+OFFSET +TYPE +VALUE
+0+0 R_X86_64_64 +\.text\+0x0+11
+0+8 R_X86_64_64 +\.text\+0x0+12
+
+
+RELOCATION RECORDS FOR \[\.text1\]:
+OFFSET +TYPE +VALUE
+0+1 R_X86_64_PC32 +\.text-0x0+3
+0+6 R_X86_64_PC32 +\.text-0x0+2
+
+
+Contents of section \.data:
+ 0000 00000000 00000000 00000000 00000000 \.+
+Contents of section \.text1:
+ 0000 e8000000 00e80000 0000 +.*
--- /dev/null
+#source: reloc-section-sym.s
+#as: --reloc-section-sym=internal
+#objdump: -rsj .data -j .text1
+#name: reloc-section-sym=internal
+
+.*: file format .*
+
+RELOCATION RECORDS FOR \[\.data\]:
+OFFSET +TYPE +VALUE
+0+0 R_X86_64_64 +named_local\+0x0+10
+0+8 R_X86_64_64 +\.text\+0x0+12
+
+
+RELOCATION RECORDS FOR \[\.text1\]:
+OFFSET +TYPE +VALUE
+0+1 R_X86_64_PC32 +named_local-0x0+4
+0+6 R_X86_64_PC32 +\.text-0x0+2
+
+
+Contents of section \.data:
+ 0000 00000000 00000000 00000000 00000000 \.+
+Contents of section \.text1:
+ 0000 e8000000 00e80000 0000 +.*
--- /dev/null
+#source: reloc-section-sym.s
+#as: --reloc-section-sym=none
+#objdump: -rsj .data -j .text1
+#name: reloc-section-sym=none
+
+.*: file format .*
+
+RELOCATION RECORDS FOR \[\.data\]:
+OFFSET +TYPE +VALUE
+0+0 R_X86_64_64 +named_local\+0x0+10
+0+8 R_X86_64_64 +\.Ltemp\+0x0+10
+
+
+RELOCATION RECORDS FOR \[\.text1\]:
+OFFSET +TYPE +VALUE
+0+1 R_X86_64_PC32 +named_local-0x0+4
+0+6 R_X86_64_PC32 +\.Ltemp-0x0+4
+
+
+Contents of section \.data:
+ 0000 00000000 00000000 00000000 00000000 \.+
+Contents of section \.text1:
+ 0000 e8000000 00e80000 0000 +.*
--- /dev/null
+ .text
+ nop
+named_local:
+ .byte 0
+.Ltemp:
+ nop
+
+.section .text1,"ax"
+ call named_local
+ call .Ltemp
+
+.data
+ .quad named_local + 16
+ .quad .Ltemp + 16
run_dump_test "x86-64-align-branch-3"
}
run_dump_test ehinterp
+
+ run_dump_test "reloc-section-sym-all"
+ run_dump_test "reloc-section-sym-internal"
+ run_dump_test "reloc-section-sym-none"
}
run_dump_test pr27198
run_dump_test pr29483
if ((symsec->flags & SEC_THREAD_LOCAL) != 0)
continue;
+ /* With --reloc-section-sym=none, skip adjustment.
+ With --reloc-section-sym=internal, only adjust relocs against
+ internal labels (e.g. .L prefix symbols in ELF). */
+ if (flag_reloc_section_sym == reloc_section_sym_none
+ || (flag_reloc_section_sym == reloc_section_sym_internal
+ && !bfd_is_local_label (stdoutput, symbol_get_bfdsym (sym))))
+ continue;
+
val = S_GET_VALUE (sym);
#if defined(TC_AARCH64) && defined(OBJ_COFF)