[PATCH] D33647: [ELF] - Linkerscript: implement NOLOAD section type.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 29 06:45:22 PDT 2017


grimar created this revision.
Herald added a subscriber: emaste.

This is PR32351

Each output section may have a type. The type is a keyword in parentheses. The following types are defined:
NOLOAD
The section should be marked as not loadable, so that it will not be loaded into memory when the program is run. 
(https://sourceware.org/binutils/docs/ld/Output-Section-Type.html#Output-Section-Type)

Parch makes such sections to be SHT_NOBITS. That looks consistent with what BFD do. Gold do something different now,
what looks like a wrong implementation simply.

Use case is next (taken from https://mcuoneclipse.com/2014/04/19/gnu-linker-can-you-not-initialize-my-variable/):

1. We want to place variable at absolute address and use next code:

  static unsigned char Var[4096] __attribute__((section (".data_noload_a")));

2. Our script looks like:

  .data_noload_a 0x2000000 : { *(.data_noload_a) }

Problem is that Var will be placed into .data section.
(if __attribute__ used with section, the variable is treated like an initialized variable, see article above)
We may want to save space, and do not write 4096 of zeroes to output file. NOLOAD is a solution.

NOLOAD makes output section to be SHT_NOBITS.


https://reviews.llvm.org/D33647

Files:
  ELF/LinkerScript.cpp
  ELF/LinkerScript.h
  ELF/ScriptParser.cpp
  test/ELF/linkerscript/noload.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33647.100609.patch
Type: text/x-patch
Size: 3129 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170529/442d7821/attachment.bin>


More information about the llvm-commits mailing list