[Bug target/126723] aarch64-darwin: temporary L.str labels miscompile literals after a weak_definition

skarnproject at gmail dot com via Gcc-bugs <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126723

--- Comment #2 from Sergey Shumakov <skarnproject at gmail dot com> ---
Thanks.  On the first point: understood, about aarch64 not being upstream. I am
now not sure this needs to be mirrored to
https://github.com/iains/gcc-darwin-arm64 as well, because:

On the second: yes, x86_64-darwin is affected too, and the defective code is
upstream.

The introducing commit r16-2939-g4db9571488eb touches only
gcc/config/darwin.cc and gcc/config/darwin-sections.def (plus testsuite), i.e.
shared Darwin files on master. So this is a GCC 16
regression affecting every Darwin target and does not originate in the
aarch64 branch.


Regarding "GCC does not include an assembler": agreed, and the hand-written .s
is only there to make the ld64 half deterministic. The part GCC owns is solely
the choice of name in
darwin_encode_section_info: any temporary-label ("L"-prefixed) name on a
literal that GCC places in a *regular* section -- __TEXT,__const in practice,
e.g. non-NUL-terminated char arrays such as libstdc++'s to_chars tables -- is
subject to this, on any Darwin target.  __TEXT,__cstring is a literal section
and is safe.  The suggested one-line fix ("*l.str.%s" unconditionally) is
equally correct for both targets, and is what the asan branch already takes.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.