Synthesized STT_FILE symbols with absolute paths and local determinism

Fangrui Song i@maskray.me
Mon Jan 4 20:02:45 GMT 2021


On Sat, Oct 31, 2020 at 10:34 AM Fangrui Song <i@maskray.me> wrote:
>
> Hi binutils folks,
>
> I saw a strange musl patch [0] which intends to add .file directives to
> crti.s and crtn.s, which made me wonder about its motivation. So I did
> some analysis:
>
> * On ARM, STB_LOCAL mapping symbols like $a are ubiquitous, produced for raw
>    assembly files like crti.s and crtn.s
> * ld synthesizes STT_FILE, if an input object files does not have STT_FILE
>    symbols (no .file directive) but has non-STT_SECTION local symbols.
> * Compiler drivers pass the absolute paths of crti.o and crtn.o to the linker
>
> =>
>
> On ARM, the output contains STT_FILE symbols with absolute paths of
> crti.o and crtn.o. The is an issue for users who pursue local
> determinism
> (https://blog.llvm.org/2019/11/deterministic-builds-with-clang-and-lld.html)
> and don't want their source artifacts to be leaked into the output.
> Unfortunately the usual -fdebug-prefix-map (-ffile-prefix-map) is not
> applicable.
>
> I wonder how GCC and ld should conspire to solve this problem.
> I also filed https://sourceware.org/bugzilla/show_bug.cgi?id=26822
>
> [0]: https://www.openwall.com/lists/musl/2020/10/30/7

Alan fixed https://sourceware.org/bugzilla/show_bug.cgi?id=26822 by
changing STT_FILE to use the basename.


More information about the Binutils mailing list