[LLVMbugs] [Bug 5929] New: difference of blockaddress goes into .data.rel. ro instead of .rodata

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Sun Jan 3 03:30:21 PST 2010


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

           Summary: difference of blockaddress goes into .data.rel.ro
                    instead of .rodata
           Product: new-bugs
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: edwintorok at gmail.com
                CC: llvmbugs at cs.uiuc.edu


The array in this function should go into a .rodata section, but with clang it
only goes into .data.rel.ro (with -fPIC):
int test(int i) {
    static const int array[] = { &&foo - &&foo, &&bar - &&foo,
                                  &&hack - &&foo };
     goto *(&&foo + array[i]);
foo:
     return 1;
bar:
     return 2;
hack:
     return 3;
}

$ clang foo.c -O1 -S -m32 -fPIC -o -
..
        .section        .data.rel.ro,"aw", at progbits
        .align  4
test.array:
        .long   (.LBA4_test_return) - (.LBA4_test_return)
        .long   (.LBA4_test_bar) - (.LBA4_test_return)
        .long   (.LBA4_test_hack) - (.LBA4_test_return)
        .size   test.array, 12

$ gcc foo.c -O1 -S -m32 -fPIC -o -
...
.section        .rodata
        .align 4
        .type   array.1248, @object
        .size   array.1248, 12
array.1248:
        .long   0
        .long   .L4-.L2
        .long   .L5-.L2

This can be reproduced by running llc on the attached testcase too.


-- 
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