Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable building with lld #75

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

heshamelmatary
Copy link
Contributor

No description provided.

@axel-h
Copy link
Member

axel-h commented Nov 23, 2023

Could you rebase this and have a look into the CI issues. Unfortunately, the logs have been deleted, so I can't see why RV32 complains about.

@heshamelmatary
Copy link
Contributor Author

Could you rebase this and have a look into the CI issues. Unfortunately, the logs have been deleted, so I can't see why RV32 complains about.

Lost track of this PR, I have now rebased and made a minor change not to fail on GCC versions that don't support retain attribute

libsel4test/include/sel4test/test.h Outdated Show resolved Hide resolved
libsel4test/include/sel4test/test.h Outdated Show resolved Hide resolved
libsel4utils/src/process.c Outdated Show resolved Hide resolved
Copy link

@Indanz Indanz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than the typo's in the commit message ("sack", should be copies to the stack), it looks fine to me now.

PT_PHDR is emitted by ld.lld but not ld.bfd. This segment should only
exist if the program header *is* part of the program memory image itself
(which is not the case in seL4, as it copies the program header in the
stack). This is important as muslc’s TLS init is relying on the existence
of PT_PHDR to get the base address of the image in memory and from that,
it calculates the TLS base for the source ELF. The calculation will be
wrong in seL4 as the program header is copied in the stack; thus it may
trigger a page fault if the new TLS base is not mapped, or affects the
integrity of programs relying on TLS variables (e.g., those with
__thread).

By setting PT_PHDR's segment to PT_NULL, muslc will skip this search and
won't do any relocations for the TLS segment which is part of the
loaded ELF image itself, thus getting the correct mapped address.

Sponsored by: DARPA.

Signed-off-by: Hesham Almatary <hesham.almatary@cl.cam.ac.uk>
unused attribute does not prevent the sections from being
garbage-collected during link-time optimisation. This may trigger
undefined references errors to [__start|__stop]_test_case symbols
that are expected to be emitted by the linker anyway.

Adding "retain" attribute makes sure that the section and its
associated symbols are kept regardless of linker's garbage
collection. Another fix could be adding "nostart-stop-gc" to the
linker flags, but since it is only one section (_test_case)
where its __start/__stop symbols are references, adding retain to
it makes more sense. This additional functionality requires
binutils version 2.36 or later.

Sponsored by: DARPA.

Signed-off-by: Hesham Almatary <hesham.almatary@cl.cam.ac.uk>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants