[llvm-bugs] [Bug 29062] New: Multiple issues with #pragma bss_seg

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Aug 19 11:29:39 PDT 2016


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

            Bug ID: 29062
           Summary: Multiple issues with #pragma bss_seg
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: richard.barton at arm.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Reproduce all of the below with:
clang -c -fms-extensions test.c
llvm-objdump -t -section-headers test.o

The first bug is that bss_seg does not result in a section of the correct type:

#pragma bss_seg(".bss2")
int a2;

a2 is correctly placed in a section called .bss2, however the resulting .bss2
section is marked DATA and not BSS.

  3 .bss2         00000004 0000000000000000 DATA
...
0000000000000000 g       .bss2           00000004 a2

Removing the pragma causes the variable to be emitted as a common variable.

The second bug is that bss_seg is ignored for some zi data:

#pragma bss_seg(".bss2")
int b2 = 0;

This results in b2 being created as a zi variable, but in the default .bss
section rather than the special .bss2 section, which is not created at all.

  3 .bss          00000004 0000000000000000 BSS
...
0000000000000000 g       .bss            00000004 b2

Combining the above two examples shows a2 going in the correct section but with
the wrong attributes, whilst b2 ends up in the wrong section but with the
correct attributes!

The third issue as that when the #pragma does work, it appears to not respect
ordering and apply across the whole file:

int a1;
#pragma bss_seg(".bss2")
int a2;

The #pragma should only apply to subsequent declarations, so a1 should be a
common symbol and a2 should end up in .bss2. Instead both a1 and a2 ending up
in .specialzi.

0000000000000000 g       .bss2           00000004 a1
0000000000000004 g       .bss2           00000004 a2

If you pop or reset the pragma bss_seg after a2 is declared then both variables
end up as common symbols:

int a1;
#pragma bss_seg(".bss2")
int a2;
#pragma bss_seg()

0000000000000004 g       *COM*           00000004 a1
0000000000000004 g       *COM*           00000004 a2

It seems that the last pragma bss_seg value wins the day and applies to all zi
data.

Finally, some zi data can be affected by the data_seg pragma:

int b1 = 0;
#pragma data_seg("specialrw")
int b2 = 0;

I would expect that given b1 is zi data, then b2 would end up in the same place
as the pragma should not apply. Instead b2 goes in "specialrw"

  3 .bss          00000004 0000000000000000 BSS
  4 specialrw     00000004 0000000000000000 DATA 
...
0000000000000000 g       .bss            00000004 b1
0000000000000000 g       specialrw               00000004 b2

-- 
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/20160819/32786088/attachment-0001.html>


More information about the llvm-bugs mailing list