Skip to content

Commit

Permalink
Fix some sections not being emitted if there's overlap between the ke…
Browse files Browse the repository at this point in the history
…ys and values of section_order
  • Loading branch information
AngheloAlf committed May 5, 2024
1 parent 34bd192 commit 9d5807c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
12 changes: 6 additions & 6 deletions slinky/src/linker_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -669,12 +669,12 @@ impl LinkerWriter<'_> {
// Keys specify the section and value specify where it will be put
// For example: `section_order: { .data: .rodata }`, meaning the `.data` of the file should be put within its `.rodata`

// This section should be placed somewhere else
if file.section_order.contains_key(section) {
continue;
}

let mut sections_to_emit_here = vec![section];
let mut sections_to_emit_here = if file.section_order.contains_key(section) {
// This section should be placed somewhere else
vec![]
} else {
vec![section]
};

// Check if any other section should be placed be placed here
for (k, v) in &file.section_order {
Expand Down
4 changes: 4 additions & 0 deletions tests/test_cases/section_order_reorder.ld
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ SECTIONS
FILL(0x00000000);
code_TEXT_START = .;
build/src/code/main.o(.text*);
build/src/code/engine.o(.sdata*);
build/src/code/entities.o(.text*);
build/src/code/background.o(.text*);
build/src/code/music.o(.text*);
Expand All @@ -23,6 +24,7 @@ SECTIONS

code_DATA_START = .;
build/src/code/main.o(.data*);
build/src/code/engine.o(.text*);
build/src/code/background.o(.data*);
build/src/code/background.o(.rodata*);
. = ALIGN(., 0x10);
Expand All @@ -31,6 +33,7 @@ SECTIONS

code_RODATA_START = .;
build/src/code/main.o(.rodata*);
build/src/code/engine.o(.data*);
build/src/code/entities.o(.data*);
build/src/code/entities.o(.rodata*);
build/src/code/sfx.o(.text*);
Expand All @@ -43,6 +46,7 @@ SECTIONS

code_SDATA_START = .;
build/src/code/main.o(.sdata*);
build/src/code/engine.o(.rodata*);
build/src/code/entities.o(.sdata*);
build/src/code/background.o(.sdata*);
. = ALIGN(., 0x10);
Expand Down

0 comments on commit 9d5807c

Please sign in to comment.