[llvm-bugs] [Bug 31888] New: assembler ELF .section type defaulted wrong for .bss-like sections not named .bss

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Feb 6 16:16:38 PST 2017


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

            Bug ID: 31888
           Summary: assembler ELF .section type defaulted wrong for
                    .bss-like sections not named .bss
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: MC
          Assignee: unassignedbugs at nondot.org
          Reporter: roland at hack.frob.com
                CC: llvm-bugs at lists.llvm.org, phosek at chromium.org
    Classification: Unclassified

In the GNU assembler, several patterns of section name make the default
type be SHT_NOBITS if none was given explicitly in the .section directive.

LLVM's assembler does this for .bss and .tbss, but not the others.

Test case:

    .text
    .data
    d0:    .space 1

    .section .bss
    a:    .space 1

    .section .bss.foo
    b:    .space 1

    .section .bss.bar,"aw"
    b1:    .space 1

    .section .tbss
    c:    .space 1

    .section .tbss.foo
    d:    .space 1

    .section .tbss.bar,"aw"
    d1:    .space 1

    .section .gnu.linkonce.b
    e:    .space 1

    .section .gnu.linkonce.b.foo
    f:    .space 1

    .section .gnu.linkonce.b.bar,"aw"
    f1:    .space 1

With GAS, all of these (except .text and .data) get SHT_NOBITS.  The cases
with no explicit flags string SHF_ALLOC|SHF_WRITE (as if the flags string
were "aw"), and .tbss* also get SHF_TLS (as if the flags string were
"awT").  .tbss.bar also gets SHT_TLS set even though T did not appear in
the explicit flags string.

With LLVM MC, only .bss and .tbss get SHT_NOBITS and only .tbss gets
SHT_TLS.  The cases with no explicit flags string (except for .bss and
.tbss) get no bits set in sh_flags.

I can see the case for not adding SHT_TLS when there was an explicit flags
string.  I won't consider it a continuing bug if the .tbss.bar case fails
to add in SHF_TLS.

When the flags or type was omitted, people expect to get the defaults based
on the section name as GAS does.

I'm only looking at the SHT_NOBITS cases here.  There are other cases where
GAS defines a default type and default flags based on the name.  You can
see them in bfd/elf.c in the special_sections_* tables.

-- 
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/20170207/1791d869/attachment.html>


More information about the llvm-bugs mailing list