[llvm-dev] Handling of section vs global name conflicts

Rafael EspĂ­ndola via llvm-dev llvm-dev at lists.llvm.org
Mon Mar 21 15:10:51 PDT 2016


On 21 March 2016 at 18:01, Evgenii Stepanov <eugenis at google.com> wrote:
> On Mon, Mar 21, 2016 at 12:29 PM, Rafael EspĂ­ndola
> <rafael.espindola at gmail.com> wrote:
>> On 21 March 2016 at 15:07, Evgenii Stepanov <eugenis at google.com> wrote:
>>> So, we emit both a global symbol for the global variable, and a local
>>> symbol for the section, with the same name?
>>
>> We could. That is what I was expecting gas to do, but I see that both
>> gas and mc produce errors.
>>
>> Handling this without MC is really hard. The name (in IR at least) can
>> conflict with implicit sections:
>>
>> @".data" = global i32 42
>>
>> One somewhat ugly option is to just produce a cleaner error when MC
>> finds the problem. With gcc one gets an error from gas.
>
> This sounds reasonable. We need better diagnostics though. And we also
> need to avoid creating such broken modules in the IR linker: imagine
> module A with the section, and module B with an _internal_ global of
> the same name. One way to do that is to track explicit section names
> in IRLinker and force rename conflicting non-externally-visible
> globals. Does it make sense?

I don't think that is sufficient given the implicit section problem.

If you really want to avoid this the best seems to be to just assign
to the .s the semantics llc thinks it has: the symbol refers to the
one produced by the GV and the section gets a STT_SECTION on the side
that doesn't conflict with anything.

Cheers,
Rafael


More information about the llvm-dev mailing list