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

fix alignment for new-style ctors when using riscv64 #34

Merged
merged 1 commit into from
Mar 26, 2024

Conversation

wbx-github
Copy link
Contributor

Recently uClibc-ng enabled UCLIBC_CTOR_DTOR for riscv64, so that f.e. C++ applications are running fine. As a side effect this breaks noMMU support. The problem is the alignment for the ctors in elf2flt. This patch fixes it.

Tested with Qemu for ARM, M68k and Xtensa with no regressions.

Thanks to sorear for the fix.

Recently uClibc-ng enabled UCLIBC_CTOR_DTOR for riscv64, so
that f.e. C++ applications are running fine. As a side effect
this breaks noMMU support. The problem is the alignment for
the ctors in elf2flt. This patch fixes it.

Tested with Qemu for ARM, M68k and Xtensa with no regressions.
@gregungerer
Copy link
Contributor

I don't have a problem with the change as-is.
Just wondering though if there is an argument you can use with ALIGN() to make it align to the natural word size of the machine?

@wbx-github
Copy link
Contributor Author

Hi Greg,

I don't have a problem with the change as-is. Just wondering though if there is an argument you can use with ALIGN() to make it align to the natural word size of the machine?

With just ALIGN() I get a syntax error with ld. Did you mean something else?

@sorear
Copy link

sorear commented Mar 25, 2024

I don't see anything in or under https://sourceware.org/binutils/docs/ld/Expressions.html that would give the target word size. I had hoped that if there was a better way to do this, a linker script expert could find it, which I am not.

The other reason I suggested using a fixed 8 instead of messing with ld-elf2flt.c is that it's consistent with the other places where FLAT is using an alignment that works for all architectures (RV64IMAC would be happy with ALIGN(2) for _stext and ALIGN(0x10) for .data, but 4 / 0x20 is the least common multiple of supported architectures, at least until someone adds tile or ia64).

@gregungerer
Copy link
Contributor

Yes I can't see any better way than just using ALIGN(8).

@gregungerer gregungerer merged commit eead8d5 into uclinux-dev:main Mar 26, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants