[cfe-dev] Feedback on feature (and status of lld linker script support?)
Christopher Friedt via cfe-dev
cfe-dev at lists.llvm.org
Sun Nov 28 07:52:57 PST 2021
Hi all,
I emailed the llvm mailing list but have not heard any response yet,
but maybe I was sent to the wrong list. Hopefully this is the right
one.
TLDR:
1) Is anyone available to provide some quick feedback on a feature [1]
before I submit it?
2) What is the status of linker script support for LLD on macOS?
I'm a bit of a newcomer to clang / llvm development and I'm working on
a feature that I hope will improve the experience on macOS for
applications that rely on custom section placement. Specifically, it
addresses this type of error:
error: argument to 'section' attribute is not valid for this target:
mach-o section specifier requires a section whose length is between 1
and 16 characters
The solution I've put together in [1] simply hashes long section names
to fit into N (16) characters. The approach is SHA256 -> base64 ->
truncate to N which is already somewhat common in various runtimes on
macOS.
I've added two options:
* -fhash-section-names=N
* hashes section names when they are > N characters
* -fhashed-section-names=outputfile
* outputs a mapping of all section names to the hash value in tabbed
CSV format
* each line is of the form: (section)\t(hash)
* would be nice to reuse any artifact file names if "outputfile" is ""
* e.g. build/foo.o => build/foo.sn, build/foo.exe => foo.sn,
build/foo => foo.sn
The above changes allow one to use linker-generated symbols to iterate
over all elements placed into a particular section. It is working
quite well for local "native_posix_64" builds of Zephyr so far. Zephyr
uses (long) custom section names extensively. Otherwise the section
name size limitation of macOS is a showstopper.
Does anyone have any quick feedback before I submit this patch to the
mailing list?
The second question I had was about LLD support for GNU style linker
scripts on macOS. I'm currently getting this error:
ld64.lld: error: zephyr/linker_zephyr_pre0.cmd: unhandled file type
Is there an option I can provide to LLD that would provide more
information about the error? Currently I'm using "-Wl,-flat_namespace,
-Wl,-undefined,warning" just to make it link, but there are several
symbols defined in the linker script that are required for the
application to run properly. Supporting GNU style linker scripts would
be immensely helpful in this case, so I'd like to make that work if at
all possible. Would be happy to patch LLD as well.
Thanks,
C
[1] https://github.com/llvm/llvm-project/compare/main...cfriedt:fhash-long-section-names
More information about the cfe-dev
mailing list