[PATCH] D24230: [ELF] Linkerscript: Fix handling of empty sections

Eugene Leviant via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 5 05:24:48 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.

On some occasions output section listed in linker script may not be written to output file. This often happens if same linker script
is used to link many applications, some of them may, for example, contain EH frames or TLS sections and some may not.

In such case two problems arise:
1) All symbols listed in such sections will be added to symbol table incorrectly. Their section index will be invalid.
2) If some symbols refer address or size of an empty section then application will fail to link, because this section is not listed in 
     OutputSections vector.

The ld and gold linkers use different approaches to address this problem:
- ld adds empty section symbols to preceding non-empty output section.
- gold makes those symbols absolute.

This patch uses gold-like way, converting all section-defined symbols to absolute. The address of an empty section is an address which it should have had in case it wasn't
empty.

Repository:
  rL LLVM

https://reviews.llvm.org/D24230

Files:
  ELF/LinkerScript.cpp
  ELF/LinkerScript.h
  test/ELF/linkerscript/symbols-synthetic.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24230.70319.patch
Type: text/x-patch
Size: 6904 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160905/722199e1/attachment.bin>


More information about the llvm-commits mailing list