-
-
Notifications
You must be signed in to change notification settings - Fork 39.7k
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
chibios: mark boot2 bootlader data readonly #21986
Conversation
It does not need to be writable, also if the .boot2 section is writable it forces some other sections to be writable, too. Fixes the following warning with GNU ld 2.41: /usr/lib/gcc/arm-none-eabi/13.2.0/../../../../arm-none-eabi/bin/ld: warning: .build/1upkeyboards_sweet16v2_kb2040_default.elf has a LOAD segment with RWX permissions ELF layout before: Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align LOAD 0x001000 0x10000000 0x10000000 0x0a858 0x0a858 RWE 0x1000 LOAD 0x00c000 0x20000000 0x1000a858 0x0081c 0x0081c R E 0x1000 LOAD 0x000820 0x20000820 0x1000b074 0x00000 0x0189c RW 0x1000 LOAD 0x000c00 0x20040c00 0x1000b074 0x00000 0x00120 RW 0x1000 LOAD 0x0000bc 0x200020bc 0x200020bc 0x00000 0x3df44 RW 0x1000 LOAD 0x000000 0x20040000 0x20040000 0x00000 0x00c00 RW 0x1000 LOAD 0x000000 0x20041000 0x20041000 0x00000 0x00c00 RW 0x1000 Section to Segment mapping: Segment Sections... 00 .boot2 .vectors .text .rodata 01 .data 02 .bss 03 .ram4 04 .heap 05 .mstack .pstack 06 .c1_mstack .c1_pstack ELF layout after: Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align LOAD 0x001000 0x10000000 0x10000000 0x0a858 0x0a858 R E 0x1000 LOAD 0x00c000 0x20000000 0x1000a858 0x0081c 0x0081c R E 0x1000 LOAD 0x000820 0x20000820 0x1000b074 0x00000 0x0189c RW 0x1000 LOAD 0x000c00 0x20040c00 0x1000b074 0x00000 0x00120 RW 0x1000 LOAD 0x0000bc 0x200020bc 0x200020bc 0x00000 0x3df44 RW 0x1000 LOAD 0x000000 0x20040000 0x20040000 0x00000 0x00c00 RW 0x1000 LOAD 0x000000 0x20041000 0x20041000 0x00000 0x00c00 RW 0x1000 Section to Segment mapping: Segment Sections... 00 .boot2 .vectors .text .rodata 01 .data 02 .bss 03 .ram4 04 .heap 05 .mstack .pstack 06 .c1_mstack .c1_pstack
@t-8ch thanks for the investigation! Unfortunately this only catches the warning for
I'm currently not sure how to fix this warning properly without resorting to workarounds as described here https://stackoverflow.com/questions/19259458/how-to-control-the-section-to-segment-mapping-in-an-elf-file. |
@KarlK90 In any case the change in this PR should make the code more correct in any case. |
Yes, we don't control the toolchains (yet?) so adding the suppressing flag isn't a viable option so far.
Absolutely, no doubt about that :-). |
I'm not sure:
|
Not on CI: ./util/docker_cmd.sh qmk compile -kb 1upkeyboards/sweet16v2/kb2040 -km default -e EXTRALDFLAGS=-Wl,--no-warn-rwx-segment
|
@tzarc This check and the corresponding flag are fairly new. |
Oh I know, I'm just saying we can't just turn it on given that a lot of our target environments don't have knowledge of the flag. |
Something like |
It does not need to be writable, also if the .boot2 section is writable it forces some other sections to be writable, too.
Fixes the following warning with GNU ld 2.41:
/usr/lib/gcc/arm-none-eabi/13.2.0/../../../../arm-none-eabi/bin/ld: warning: .build/1upkeyboards_sweet16v2_kb2040_default.elf has a LOAD segment with RWX permissions
ELF layout before:
ELF layout after:
Checklist