mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-21 04:42:53 +08:00
975f8a9e31
Giving linker script symbols defined outside of output sections a section-relative value early, leads to them being used in expressions as if they were defined inside an output section. This can mean loss of the section VMA, and wrong results. ld/ PR ld/18963 * ldexp.h (struct ldexp_control): Add rel_from_abs. (ldexp_finalize_syms): Declare. * ldexp.c (new_rel_from_abs): Keep absolute for expressions outside of output section statements. Set rel_from_abs. (make_abs, exp_fold_tree, exp_fold_tree_no_dot): Clear rel_from_abs. (struct definedness_hash_entry): Add final_sec, and comment. (update_definedness): Set final_sec. (set_sym_sections, ldexp_finalize_syms): New functions. * ldlang.c (lang_process): Call ldexp_finalize_syms. ld/testsuite PR ld/18963 * ld-scripts/pr18963.d, * ld-scripts/pr18963.t: New test. * ld-scripts/expr.exp: Run it. * ld-elf/provide-hidden-2.ld: Explicitly make "dot" absolute. * ld-mips-elf/gp-hidden.sd: Don't care about _gp section. * ld-mips-elf/no-shared-1-n32.d: Don't care about symbol shown at start of .data section. * ld-mips-elf/no-shared-1-n64.d: Likewise. * ld-mips-elf/no-shared-1-o32.d: Likewise.
27 lines
563 B
Makefile
27 lines
563 B
Makefile
#as: -march=from-abi -mabi=64 -EB
|
|
#ld: -melf64btsmip -T no-shared-1.ld
|
|
#objdump: -dr -j.text -j.data -j.got
|
|
|
|
.*
|
|
|
|
|
|
Disassembly of section \.text:
|
|
|
|
0000000000050000 <__start>:
|
|
50000: 3c020007 lui v0,0x7
|
|
50004: 64428000 daddiu v0,v0,-32768
|
|
50008: df828020 ld v0,-32736\(gp\)
|
|
5000c: df828020 ld v0,-32736\(gp\)
|
|
#...
|
|
Disassembly of section \.data:
|
|
|
|
0000000000060000 .*:
|
|
60000: 00000000 .*
|
|
60004: 00068000 .*
|
|
#...
|
|
Disassembly of section \.got:
|
|
|
|
0000000000060010 <_GLOBAL_OFFSET_TABLE_>:
|
|
\.\.\.
|
|
60018: 80000000 00000000 00000000 00068000 .*
|