[llvm-commits] Add scope support for Absolute symbols

Sid Manning sidneym at codeaurora.org
Wed Oct 17 20:42:58 PDT 2012


On 10/17/2012 03:29 PM, Nick Kledzik wrote:
>
> On Oct 17, 2012, at 8:17 AM, Sid Manning wrote:
>> Add support for this cases where absolute symbols binding types.  This is the example:
>>
>> .globl absSymbol
>> .set absSymbol,0xC0000
>> .type absSymbol, @object
>>
>> .local absSymbol2
>> .set absSymbol2,0xD0000
>> .type absSymbol2, @object
>>
>> This patch changes the following:
>>   * Moves enum Scope from DefinedAtom.h to Atom.h
>>   * Adds scope method to AbsoluteAtom class
>>   * Updates YAML to print scope of AbsoluteAtoms
>>   * Update Native Reader/Writer to handle this new, "attribute"
>>   * Adds testcase
>
> When I first designed AbsoluteAtoms, I was thinking of embedded systems where you might have reset vectors or functions at fixed addresses, and those symbolic names would not be need in the final linked image.   But, assembly programs (whether they realize it or not) can create absolute symbols with a simple "foo = 10".  And we need to preserve round tripping ELF object files through the Atom model.
>
> My question is there any other attributes we need to preserve on absolute atoms (besides scope)?]

The attributes we preserve will to some degree on the rules required for 
a symbol to be classified as an absolute atom.  If the type is limited 
to STT_OBJECT then contentType need not be preserved.

For all symbol types ELF allows OS and processor specific binding, 
STB_LOOS/HIOS and STB_LOPROC/HIPROC so some format/os/arch specific 
hooks may be required to process these correctly.  These are valuable 
numbers however and I don't know of any usage at the moment.  Symbol 
types have similar STT_LOOS/HIOS and STT_LOPROC/HIPROC.  Sections have 
SHN_LOOS/HIOS LOPROC/HIPROC

As with fixups some of the Atom's methods may need to have the ability 
to call out to target specific routines.  Hexagon uses SHN_PROC range 
for common small data and the exact way that will be handled is still 
under discussion.

>
>
> The patch looks good except for one issue:
>
>> +    t = ELF::STT_OBJECT;
>> +    if (aa->scope() == AbsoluteAtom::scopeLinkageUnit)
>> +      symbol->st_other = ELF::STV_HIDDEN;
>> +    if (aa->scope() == AbsoluteAtom::scopeTranslationUnit)
>> +      b = ELF::STB_LOCAL;
>> +    else
>> +      b = ELF::STB_GLOBAL;
> This should be a switch statement so that if another value is added to Scope, we get a compiler warning.

I will make this change.

>
> -Nick
>


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



More information about the llvm-commits mailing list