<div dir="ltr"><a class="gmail_plusreply" id="m_-6891638192978040380plusReplyChip-0" href="mailto:maskray@google.com" target="_blank">+Fangrui Song</a> for general LLD stuff<br><a class="gmail_plusreply" id="m_-6891638192978040380plusReplyChip-1" href="mailto:jezng@fb.com" target="_blank">+Jez Ng</a> for ld64.lld stuff<div><a class="gmail_plusreply" id="plusReplyChip-2" href="mailto:rnk@google.com" tabindex="-1">+Reid Kleckner</a> for discussion around section/symbol reduction<br><br>I'm guessing it'll be best to keep each issue in a separate thread - and the previous thread on llvm-dev ( <a href="https://groups.google.com/g/llvm-dev/c/YzHbrfTxLCY/m/ssYtlxIdAwAJ">https://groups.google.com/g/llvm-dev/c/YzHbrfTxLCY/m/ssYtlxIdAwAJ</a> )<br><br></div><div>The section name hashing might be more of a clang feature than an LLVM one - if it's specifically for user-specified sections, etc. It could have some overlap with some symbol name length issues I've been considering for a while with somewhat similar strategies (hash, but then have a lookup table). I'm not sure who's going to be best to actually make the final call on whether what you're proposing is suitable for Clang/LLVM</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Nov 28, 2021 at 7:53 AM Christopher Friedt via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi all,<br>
<br>
I emailed the llvm mailing list but have not heard any response yet,<br>
but maybe I was sent to the wrong list. Hopefully this is the right<br>
one.<br>
<br>
TLDR:<br>
1) Is anyone available to provide some quick feedback on a feature [1]<br>
before I submit it?<br>
2) What is the status of linker script support for LLD on macOS?<br>
<br>
I'm a bit of a newcomer to clang / llvm development and I'm working on<br>
a feature that I hope will improve the experience on macOS for<br>
applications that rely on custom section placement. Specifically, it<br>
addresses this type of error:<br>
<br>
error: argument to 'section' attribute is not valid for this target:<br>
mach-o section specifier requires a section whose length is between 1<br>
and 16 characters<br>
<br>
The solution I've put together in [1] simply hashes long section names<br>
to fit into N (16) characters. The approach is SHA256 -> base64 -><br>
truncate to N which is already somewhat common in various runtimes on<br>
macOS.<br>
<br>
I've added two options:<br>
* -fhash-section-names=N<br>
  * hashes section names when they are > N characters<br>
* -fhashed-section-names=outputfile<br>
  * outputs a mapping of all section names to the hash value in tabbed<br>
CSV format<br>
  * each line is of the form: (section)\t(hash)<br>
  * would be nice to reuse any artifact file names if "outputfile" is ""<br>
  * e.g. build/foo.o => build/<a href="http://foo.sn" rel="noreferrer" target="_blank">foo.sn</a>, build/foo.exe => <a href="http://foo.sn" rel="noreferrer" target="_blank">foo.sn</a>,<br>
build/foo => <a href="http://foo.sn" rel="noreferrer" target="_blank">foo.sn</a><br>
<br>
The above changes allow one to use linker-generated symbols to iterate<br>
over all elements placed into a particular section. It is working<br>
quite well for local "native_posix_64" builds of Zephyr so far. Zephyr<br>
uses (long) custom section names extensively. Otherwise the section<br>
name size limitation of macOS is a showstopper.<br>
<br>
Does anyone have any quick feedback before I submit this patch to the<br>
mailing list?<br>
<br>
The second question I had was about LLD support for GNU style linker<br>
scripts on macOS. I'm currently getting this error:<br>
<br>
ld64.lld: error: zephyr/linker_zephyr_pre0.cmd: unhandled file type<br>
<br>
Is there an option I can provide to LLD that would provide more<br>
information about the error? Currently I'm using "-Wl,-flat_namespace,<br>
-Wl,-undefined,warning" just to make it link, but there are several<br>
symbols defined in the linker script that are required for the<br>
application to run properly. Supporting GNU style linker scripts would<br>
be immensely helpful in this case, so I'd like to make that work if at<br>
all possible. Would be happy to patch LLD as well.<br>
<br>
Thanks,<br>
<br>
C<br>
<br>
[1] <a href="https://github.com/llvm/llvm-project/compare/main...cfriedt:fhash-long-section-names" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/compare/main...cfriedt:fhash-long-section-names</a><br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div>