[PATCH] D24298: [ELF] Linkerscript: Implement LOADADDR

Eugene Leviant via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 7 09:31:16 PDT 2016


evgeny777 created this revision.
evgeny777 added reviewers: ruiu, rafael.
evgeny777 added subscribers: grimar, ikudrin, llvm-commits.
evgeny777 set the repository for this revision to rL LLVM.
evgeny777 added a project: lld.

This patch does the following:

1) Implements LOADADDR function in linker script processor
2) Fixes bug when segment is created for section which has LMA. (*)

* Current **may** create segments incorrectly in the following case

```
SECTIONS {
  . = 0;
   .aaa : AT(0x1000) { *(.aaa) }
   . = 0x1000;
   .bbb : { *(.bbb) }
}
```
In the example above section .aaa has VMA = 0 and LMA = 0x1000. Section .bbb has VMA = 0x1000 and LMA = 0x2000.
This is because according to https://sourceware.org/binutils/docs-2.20/ld/Output-Section-LMA.html

> If neither AT nor AT> is specified for an allocatable section, the linker will set the LMA such that the difference between VMA and LMA for the section is the same as the preceding output section in the same region

This means that under certain circumstances separate PT_LOAD should be created for output section, even though it doesn't have explicit LMA specification.
This patch creates separate segment for every allocatable section after section with explicit LMA.

Repository:
  rL LLVM

https://reviews.llvm.org/D24298

Files:
  ELF/LinkerScript.cpp
  ELF/LinkerScript.h
  ELF/OutputSections.h
  ELF/Writer.cpp
  test/ELF/linkerscript/at.s
  test/ELF/linkerscript/loadaddr.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24298.70546.patch
Type: text/x-patch
Size: 10373 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160907/c2e6cb61/attachment.bin>


More information about the llvm-commits mailing list