[llvm-bugs] [Bug 45228] New: Cannot dump all stack sizes in fully linked output if some entries come from different sections

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Mar 17 09:10:13 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=45228

            Bug ID: 45228
           Summary: Cannot dump all stack sizes in fully linked output if
                    some entries come from different sections
           Product: tools
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: llvm-readobj
          Assignee: unassignedbugs at nondot.org
          Reporter: jh7370.2008 at my.bristol.ac.uk
                CC: jh7370.2008 at my.bristol.ac.uk, llvm-bugs at lists.llvm.org

Imagine the following piece of code:

__attribute__((section(".wibble")))
int baz () {
    int a[42];
    return sizeof(a);
}

int _start(){
    int x = 1;
    return baz() + x; 
}

When compiled, this will produce sections ".wibble" and ".text", each with
their own .stack_sizes section. When linked, .wibble and .text remain as
separate sections, but the two .stack_sizes sections are concatenated into one.
The .stack_sizes section has a sh_link field pointing to the section containing
the functions it refers to. This works fine in the ET_REL object, but in the
final link, the linker has to pick one section to use. llvm-readobj uses the
sh_link value to determine which symbols are candidates for each individual
stack size entry: if they are in the "wrong" section, they don't get
considered. This has the result of not finding symbols for some sections. For
the above piece of code, I get the following output from llvm-readelf:

C:\Work\PPRBUG-25593> C:\llvm\build\Debug\bin\llvm-readelf.exe --stack-sizes
repro.elf

Stack Sizes:
         Size     Function
           24     _start
C:\llvm\build\Debug\bin\llvm-readelf.exe: warning: 'repro.elf': could not
identify function symbol for stack size entry
           56     ?

I think we need to do two things:
1) Set the sh_link to 0 in the linked output. This will require an LLD change.
2) Change llvm-readelf to not do the section check in the event that sh_link is
0. There shouldn't be any ambiguity between symbols in this case, so it is not
a degradation in correctness, although I suppose technically there's nothing
stopping symbols being in non-alloc sections, in which case we might want to
special case that (although they won't be STT_FUNC, so there's probably no
need).

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200317/b6e4a9aa/attachment.html>


More information about the llvm-bugs mailing list