[LLVMdev] defining symbols with lld

Sean Silva chisophugis at gmail.com
Fri Aug 23 15:14:41 PDT 2013


On Fri, Aug 23, 2013 at 4:54 PM, Shankar Easwaran
<shankare at codeaurora.org>wrote:

> Hi Nick,
>
> Thanks for your reply.
>
>
> On 8/23/2013 3:40 PM, Nick Kledzik wrote:
>
>>
>> These are the changes I plan to make, and some questions that I have
>>
>> a) Define a new contentType for DefinedAtoms to say 'Expression'
>> b) Create a new class ExprnAtom derived from DefinedAtom
>> c) The expression could also contain various functions that could be set
>> in the expression, how should that be represented ?
>> I don’t understand this.  I thought expression where like "_foo + 10”.
>>  What do you mean by functions set in expression?
>>
> Linker scripts can set expressions to be, some of the examples that I have
> seen are :-
>
> foo=SIZEOF(.text)
> foo=14+ADDR(.data)
> foo=ALIGN(4096)
>
>
However, the kinds of expressions allowed in --defsym is much more
restricted. From the GNU ld manpage:

       --defsym=symbol=expression
           Create a global symbol in the output file, containing the
absolute address given by expression.  You may use this option as many
times as
           necessary to define multiple symbols in the command line.  *A
limited form of arithmetic is supported for the expression in this context:
you may*
*           give a hexadecimal constant or the name of an existing symbol,
or use "+" and "-" to add or subtract hexadecimal constants or symbols.* If you
           need more elaborate expressions, consider using the linker
command language from a script.  Note: there should be no white space
between symbol,
           the equals sign ("="), and expression.


The full linker script expression language is another whole can of worms,
and we probably only want to implement a judiciously chosen subset of the
functionality. If you haven't already, check out <
http://sourceware.org/binutils/docs/ld/Expressions.html>. It is
well-written.

-- Sean Silva
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130823/b0063f6d/attachment.html>


More information about the llvm-dev mailing list