Skip to content

Instantly share code, notes, and snippets.

@paranlee
Created June 2, 2021 11:07
Show Gist options
  • Select an option

  • Save paranlee/015f7a7f2fd4eaf504c13f9a1dccd258 to your computer and use it in GitHub Desktop.

Select an option

Save paranlee/015f7a7f2fd4eaf504c13f9a1dccd258 to your computer and use it in GitHub Desktop.
Linux kernel v5.4.123 64bit RISC-V vmlinux.lds sample lds comment
/*
* Helper macros to support writing architecture specific
* linker scripts.
*
* A minimal linker scripts has following content:
* [This is a sample, architectures may have special requiriements]
*/
OUTPUT_FORMAT(...)
OUTPUT_ARCH(...)
ENTRY(...)
SECTIONS
{
. = START;
__init_begin = .;
HEAD_TEXT_SECTION
INIT_TEXT_SECTION(PAGE_SIZE)
INIT_DATA_SECTION(...)
PERCPU_SECTION(CACHELINE_SIZE)
__init_end = .;
_stext = .;
TEXT_SECTION = 0
_etext = .;
_sdata = .;
RO_DATA_SECTION(PAGE_SIZE)
RW_DATA_SECTION(...)
_edata = .;
EXCEPTION_TABLE(...)
NOTES
BSS_SECTION(0, 0, 0)
_end = .;
STABS_DEBUG
DWARF_DEBUG
DISCARDS // must be the last
}
/*
* [__init_begin, __init_end] is the init section that may be freed after init
* // __init_begin and __init_end should be page aligned, so that we can
* // free the whole .init memory
* [_stext, _etext] is the text section
* [_sdata, _edata] is the data section
*
* Some of the included output section have their own set of constants.
* Examples are: [__initramfs_start, __initramfs_end] for initramfs and
* [__nosave_begin, __nosave_end] for the nosave data
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment