[LLVMdev] [lld] Handling non SHF_ALLOC sections.

Shankar Easwaran shankare at codeaurora.org
Mon Sep 16 18:48:52 PDT 2013


Hi Michael,

On 9/16/2013 7:23 PM, Michael Spencer wrote:
> Debug info linking is currently broken due to how we handle reading and
> laying out non SHF_ALLOC sections. I posted a patch that partially fixes
> this, but it's both the wrong approach and doesn't handle multiple input
> files with debug info (wrong relocation values).
>
> The first issue is representing non SHF_ALLOC atoms in the Atom model. We
> currently don't have a type for this, and DefinedAtom.cpp makes assumptions
> about the permissions of an Atom based on their type, so it's hard to use
> an existing type.
Can we parse the Debug sections into atoms too ? This way we could 
associate Debug information associated with DefinedAtoms (seperate 
reference types, probably).

The advantage of this approach would be that Garbage collection would 
remove all the unneeded references automatically when the definedatom is 
removed.

I think Nick also mentioned about a similiar way a while back.

> The next problem is in the ELF writer. It currently cannot handle
> AtomSections that are not in a segment as file offsets and addresses are
> never set. This means that assignOffsets is not called, and that the atoms
> within are never added to the _atomToAddressMap. However, we can't just add
> them to that map with their virtual address, as they don't have a virtual
> address. We need to use the symbol value, which is the offset into the
> section. My current hack to fix this is to call
> assignVirtualAddresses(-fileoffset) and then explicitly added them to the
> _atomToAddressMap.
>
> Any ideas for the proper fix here?
There is a way that we can handle this without lot of tweaks.

a) Assign the debug sections part of a linker internal segment(the 
segment would not appear in the output file), hasOutputSegment will 
return true for a debug section.

b) Around lines 623, in DefaultLayout, we find out if the section is 
associated with the special debug section, we add this sepecial segment 
to the list of segments

c) Around lines 731 in DefaultLayout.h, we compare the segment type 
against the linker internal segment types, and assign offsets for the 
debug section. Lets not set the virtual addresses for these sections. If 
there is a need for assigning virtual addresses, you could change the 
second loop that assigns virtual addresses to deal with that too.

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