-
-
Notifications
You must be signed in to change notification settings - Fork 482
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
Section alignment requirements and inserted padding #1399
Comments
I've also discovered that an alignment of 1 for a .rodata is capable of truncating/overwriting symbols explicitly sized 16 |
Can you give me an example to demonstrate the issue? As far as I know, GNU ld respects the section alignment. |
#include <unistd.h>
#include <stdint.h>
#include <stdalign.h>
uint64_t ffilex(char const []);
int main() {
uint64_t r = ffilex("showU64B ptr x = VWrite ptr (SubB (ReplicateB 48) (MovmB x)) %c\n");
write(1 , r == 10235907949189046785ul ? "OK\n" : "KO\n", 3);
return 0;
}``` Raw relocatable |
I have no idea what your |
On this input it returns a fixed number IFF the .rodata is setup correctly, |
I wasted a few hours finding out that sh_align is handled differently by ld then mold (and gold)
ld ignores it, mold respects it and will pad data with zeros
The thing is, programs cannot rely on either behavior (eg. rip-rela addressing into a .rodata), since if using the wrong linker it generates the worst kind of obscure, delayed failures.
Perhaps mold should emit a warning rather than silently insert padding between elements of a section
The text was updated successfully, but these errors were encountered: