[LLVMbugs] [Bug 9356] New: missing warning on inconsistent function section attribute

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Mar 1 10:31:39 PST 2011


http://llvm.org/bugs/show_bug.cgi?id=9356

           Summary: missing warning on inconsistent function section
                    attribute
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: pageexec at freemail.hu
                CC: llvmbugs at cs.uiuc.edu, pageexec at freemail.hu
            Blocks: 4068


# cat a.c
void __attribute__((section(".foo"))) f(void);
void __attribute__((section(".bar"))) f(void) {}
# gcc -O2 a.c -c -W -Wall
# objdump -drw a.o

a.o:     file format elf32-i386


Disassembly of section .bar:

00000000 <f>:
   0:   55                      push   %ebp
   1:   89 e5                   mov    %esp,%ebp
   3:   5d                      pop    %ebp
   4:   c3                      ret
# ./image/bin/clang -O2 a.c -c -W -Wall
# objdump -drw a.o

a.o:     file format elf32-i386


Disassembly of section .foo:

00000000 <f>:
   0:   c3                      ret

there're two issues here. one's that gcc chooses the attribute from the
definition whereas clang chooses it from the declaration, so this is an
inconsistency (but it's a wrong code case so it's not that important).

the second and really important problem is that neither compiler warned about
the section mismatch.

FYI, the real case is in linux (acpi_status __initdata
acpi_os_initialize(void); -> should be __init) and fortunately resulted in code
being placed in a non-executable data section, so it was caught at runtime.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list