[PATCH] D22683: [ELF] Symbol assignment within input section list

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 2 04:30:11 PDT 2016


grimar added a comment.

In https://reviews.llvm.org/D22683#502851, @ruiu wrote:

> Sorry to bring this back again, but I'm wondering why we can't create absolute symbols. This is different from what GNU linkers do, but looks like difference between section-relative symbols and absolute symbols don't matter. If we create absolute symbols, we can remove the virtual input section class.


I think one of the reasons can be:
(https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/4/html/Using_ld_the_GNU_Linker/expressions.html)
"The position of the expression within the linker script determines whether it is absolute or
relative. An expression which appears within an output section definition is relative to the
base of the output section. An expression which appears elsewhere will be absolute.

A symbol set to a relative expression will be relocatable if you request relocatable output
using the ‘-r’ option. That means that a further link operation may change the value of
the symbol. The symbol’s section will be the section of the relative expression"

For absolute symbols there is ABSOLUTE() keyword:
ABSOLUTE(exp)
Return the absolute (non-relocatable, as opposed to non-negative) value of the
expression exp. Primarily useful to assign an absolute value to a symbol within
a section definition, where symbol values are normally section relative.


================
Comment at: ELF/Writer.cpp:714
@@ +713,3 @@
+  // of each input section, so must be called after we assign section offsets
+  Script<ELFT>::X->assignSectionSymbols();
+
----------------
Missing dot at the end of last sentence.


https://reviews.llvm.org/D22683





More information about the llvm-commits mailing list