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

Add support for encrypting elfs with section holes within segments #150

Merged
merged 1 commit into from
Oct 14, 2024

Conversation

will-v-pi
Copy link
Contributor

While looking at raspberrypi/pico-examples#558 I've discovered that no_flash binaries can end up with a 4 byte gap between the .text and .rodata sections in the ELF file. This creates a gap between sections in the ELF file, within a single segment.

This PR adds support to picotool encrypt for these binaries - without this patch there would be a word of 0s written to the ELF file between the .text and .rodata sections, rather than the encrypted 0s for that word.

@kilograham Is this also a bug in the SDK linker scripts, as they contain . = ALIGN(4);, but the actual alignment of the .text and .rodata sections in the ELF files produced is 8 bytes? This seems to be what's causing the holey ELF files, and can be prevented with this diff to extend the .text section up to the .rodata section.

--- a/src/rp2_common/pico_crt0/rp2350/memmap_no_flash.ld
+++ b/src/rp2_common/pico_crt0/rp2350/memmap_no_flash.ld
@@ -70,10 +70,10 @@ SECTIONS
         *(.dtors)
 
         *(.eh_frame*)
+        . = ALIGN(8);
     } > RAM
 
     .rodata : {
-        . = ALIGN(4);
         *(.rodata*)
         *(.srodata*)
         . = ALIGN(4);

@will-v-pi will-v-pi added this to the 2.0.1 milestone Oct 2, 2024
@will-v-pi will-v-pi merged commit b62ead3 into develop Oct 14, 2024
31 checks passed
@will-v-pi will-v-pi deleted the holey-elfs branch October 14, 2024 14:44
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.

1 participant