If the symbol defined by PROVIDE in the link script is not in SECTION,
the symbol is placed in the ABS section. The linker considers that
symbols in the ABS section do not need to calculate PC relative offsets.
Symbols in ABS sections should calculate PC relative offsets normally
based on relocations.
/* The r_symndx will be STN_UNDEF (zero) only for relocs against symbols
from removed linkonce sections, or sections discarded by a linker
script. Also for R_*_SOP_PUSH_ABSOLUTE and PCREL to specify const. */
- if (r_symndx == STN_UNDEF || bfd_is_abs_section (sec))
+ if (r_symndx == STN_UNDEF)
{
defined_local = false;
resolved_local = false;
run_dump_test "ie-le-relax"
run_dump_test "tlsdesc_abs"
run_dump_test "tlsdesc_extreme"
+ run_dump_test "provide_abs"
+ run_dump_test "provide_noabs"
+
}
--- /dev/null
+#source: provide_sym.s
+#as:
+#ld: -T provide_abs.ld
+#objdump: -d
+
+.*: +file format .*
+
+#...
+ 0: 58001085 beq \$a0, \$a1, 16 # 10 <fun1>
+ 4: 40000c80 beqz \$a0, 12 # 10 <fun1>
+ 8: 54000800 bl 8 # 10 <fun1>
+#pass
--- /dev/null
+PROVIDE(fun1 = 0x10);
--- /dev/null
+#source: provide_sym.s
+#as:
+#ld: -T provide_noabs.ld
+#objdump: -d
+
+.*: +file format .*
+
+
+#...
+ 0: 58001085 beq \$a0, \$a1, 16 # 10 <fun1>
+ 4: 40000c80 beqz \$a0, 12 # 10 <fun1>
+ 8: 54000800 bl 8 # 10 <fun1>
+#pass
--- /dev/null
+SECTIONS
+{
+ .text :
+ {
+ PROVIDE(fun1 = 0x10);
+ }
+}
--- /dev/null
+ .text
+ .globl main
+ .type main, @function
+main:
+ beq $a0,$a1,%b16(fun1)
+ beqz $a0,%b21(fun1)
+ bl %b26(fun1)