[PATCH] D66279: [ELF] Make LinkerScript::assignAddresses iterative
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 15 18:35:52 PDT 2019
MaskRay added a comment.
Investigated a bit how ld.bfd works.
SECTIONS {
. = 0x1000;
a = b + 1; b = c + 1; c = d + 1; d = e + 1; e = f + 1; f = g + 1; g = h + 1; h = .;
}
// ld/ld-new -T a.lds a.o -o a
// undefined symbol `b' referenced in expression
SECTIONS {
. = 0x1000;
a = b + 1; b = c + 1; c = d + 1; d = e + 1; e = f + 1; f = g + 1; g = .;
}
// st_value(a) is incorrect 6, not 0x1006.
// st_value(a) is correct (0x1005) with one less variable.
In either case, `lang_do_assignments` ran 3 times.
- lang_do_assignments (lang_mark_phase_enum); // in ld/ldlang.c:lang_process
- lang_do_assignments (lang_assigning_phase_enum); // in ld/ldlang.c:lang_relax_sections
- lang_do_assignments (lang_final_phase_enum); // in ld/ldlang.c:lang_process
The initial 3 calls allow it to compute a slightly longer chain, though a new `lang_do_assignments (lang_assigning_phase_enum);` only allows it to compute the case with one more variable. The iterative process we use can emulate its behavior.
Repository:
rLLD LLVM Linker
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D66279/new/
https://reviews.llvm.org/D66279
More information about the llvm-commits
mailing list