[llvm-commits] Add scope support for Absolute symbols

Nick Kledzik kledzik at apple.com
Wed Oct 17 13:29:57 PDT 2012


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 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.

-Nick



More information about the llvm-commits mailing list