[llvm] r230411 - Support SHF_MERGE sections in COMDATs.

Rafael Espíndola rafael.espindola at gmail.com
Thu Feb 26 05:16:46 PST 2015


On 26 February 2015 at 05:22, Mikael Holmén <mikael.holmen at ericsson.com> wrote:
> Hi Rafael,
>
> With this change our out-of-tree target breaks so I'm a little bit curious.
>
> In our backend we override the text section
>
>   // .text
>   TextSection = getContext().getELFSection("code", ELF::SHT_LOUSER + 0,
>                                            ELF::SHF_ALLOC |
> ELF::SHF_EXECINSTR);
>
> so we get ".code" in the assembler output instead of ".text".

What about comdat sections? Don't you need to use ELF::SHT_LOUSER for them too?

> With the "old" implementation of TargetLoweringObjectFileELF::
> SelectSectionForGlobal this worked fine, since it had
>
>   if (Kind.isText()) return TextSection;
>
> where it really used our overridden TextSection.
>
> However, with this commit we now end up in
>
>   return getContext().getELFSection(Name, getELFSectionType(Name, Kind),
> Flags,
>                                     EntrySize, Group,
>                                     EmitUniqueSection &&
> !UniqueSectionNames);
>
> with Name fetched from getSectionPrefixForGlobal, which just says ".text",
> and we end up with ".text" in the assembler output instead of our wanted
> ".code".

Why is the name an issue? The intent on ELF was that names were not
relevant. I can see the SHT being important.


> Of course we can handle more cases in our backend in our own overridden
> version of SelectSectionForGlobal function, I'm just wondering if this was
> an expected outcome of the patch? Have we just been lucky it worked for us
> so far?

The intent was to make sure that all sections use the same code path.
So now .text and .text._Z... take the same path. If you need to use
ELF::SHT_LOUSER for .text._Z..., you already had to override
SelectSectionForGlobal, no?

Cheers,
Rafael




More information about the llvm-commits mailing list