Skip to content

Commit

Permalink
zehn_loader: Make sure padding ends up in the raw binary
Browse files Browse the repository at this point in the history
The previous alignment instruction was a noop, as there was nothing past it.
Put alignment into a custom section and make sure it ends up in the binary.
  • Loading branch information
Vogtinator committed May 17, 2024
1 parent e07d805 commit bf2d057
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ndless-sdk/tools/zehn_loader/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ zehn_loader.tns.elf: loader.cpp
$(GXX) $(GXXFLAGS) $^ -o $@

zehn_loade%.tns: zehn_loade%.tns.elf
$(OBJCOPY) -O binary $^ $@
$(OBJCOPY) --set-section-flags .pad=alloc,load,contents -O binary $^ $@

zlib/Makefile: ../../thirdparty/zlib/configure
mkdir -p zlib
Expand Down
8 changes: 5 additions & 3 deletions ndless-sdk/tools/zehn_loader/ldscript
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ SECTIONS
*(.got.plt);
*(.got);
}
/* .bss before .data, to make sure space is allocated for it in the binary file */
.bss : {
*(.bss);
*(.bss.*);
Expand All @@ -20,7 +19,10 @@ SECTIONS
*(.data);
*(.data.*);
}

. = ALIGN(4);
/* Put padding into its own section which is force included
by the objcopy call. This ensures that NOBITS data is filled. */
.pad : {
. = ALIGN(4);
}
}
zehn_start = .;

0 comments on commit bf2d057

Please sign in to comment.