[LLVMdev] defining symbols with lld

Shankar Easwaran shankare at codeaurora.org
Fri Aug 23 15:17:52 PDT 2013


On 8/23/2013 5:14 PM, Sean Silva wrote:
> 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.
I agree, but I think we need to have one expression evaluator in lld. 
Linker scripts that define expressions follow the same bucket
as expressions being dealt in the command line.

Thanks

Shankar Easwaran

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by the Linux Foundation




More information about the llvm-dev mailing list