Skip to content

Commit

Permalink
flat.lds: discard .comment and .note
Browse files Browse the repository at this point in the history
Compilers like gcc may place information like compiler versions, build IDs,
etc. into dedicate sections called .comment or .note. These sections may be
placed even before the entry point if the linker script does not specify how
these sections shall be handled. This can be problematic as it is assumed that
the beginning of the image is a 12-byte multiboot header, followed by the entry
point of the image. It has also been met that ignoring these sections in the
linker script leads to a very small bss_start (mostly <1K), which leads the test
program to crash when it tries to initialize its .bss section.

Discard these sections as these sections contain compiler/linker-specific
information which is mostyl useless at runtime.

Signed-off-by: Junjie Mao <[email protected]>
  • Loading branch information
junjiemao1 authored and shenfang2019 committed Aug 26, 2022
1 parent 7e5465b commit 361261a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions x86/flat.lds
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ SECTIONS
.bss : { *(.bss) }
. = ALIGN(4K);
edata = .;

/DISCARD/ : {
*(.comment .comment.* .note .note.*)
}
}

ENTRY(start)

0 comments on commit 361261a

Please sign in to comment.