public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Synthesized STT_FILE symbols with absolute paths and local determinism
@ 2020-10-31 17:34 Fangrui Song
  2021-01-04 20:02 ` Fangrui Song
  0 siblings, 1 reply; 2+ messages in thread
From: Fangrui Song @ 2020-10-31 17:34 UTC (permalink / raw)
  To: binutils

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Synthesized STT_FILE symbols with absolute paths and local determinism
  2020-10-31 17:34 Synthesized STT_FILE symbols with absolute paths and local determinism Fangrui Song
@ 2021-01-04 20:02 ` Fangrui Song
  0 siblings, 0 replies; 2+ messages in thread
From: Fangrui Song @ 2021-01-04 20:02 UTC (permalink / raw)
  To: binutils

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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-01-04 20:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-31 17:34 Synthesized STT_FILE symbols with absolute paths and local determinism Fangrui Song
2021-01-04 20:02 ` Fangrui Song

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).