[LLVMbugs] [Bug 2143] New: glibc-2.7/csu/initfini. s generated by llvm-gcc not understood by glibc build system

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Wed Mar 12 08:51:18 PDT 2008


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

           Summary: glibc-2.7/csu/initfini.s generated by llvm-gcc not
                    understood by glibc build system
           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


Created an attachment (id=1529)
 --> (http://llvm.org/bugs/attachment.cgi?id=1529)
initfini.c

Generating crti.S, crtn.S, initfini.s is done via a call to compiler -S, and
postprocessed using sed.
Unfortunately llvm's output is not what glibc's build system expects, and the
result is wrong crti.S, crtn.S with a linker error about duplicate symbols.

As a comment in csu/Makefile says:
"In ELF we also install crti.o and crtn.o, special "initializer" and
"finalizer" files used in the link to make the .init and .fini sections work
right; both these files are built (in an arcane manner) from initfini.c"

This is the linker error:
/home/edwin/llvm/install/bin/llvm-gcc -nostdlib -nostartfiles -o
/home/edwin/glibc-2.7/build-tree/i386-libc/iconv/iconvconfig 
-Wl,-dynamic-linker=/lib/ld-linux.so.2   -Wl,-z,combreloc -Wl,-z,relro
-Wl,--hash-style=both /home/edwin/glibc-2.7/build-tree/i386-libc/csu/crt1.o
/home/edwin/glibc-2.7/build-tree/i386-libc/csu/crti.o
`/home/edwin/llvm/install/bin/llvm-gcc --print-file-name=crtbegin.o`
/home/edwin/glibc-2.7/build-tree/i386-libc/iconv/iconvconfig.o
/home/edwin/glibc-2.7/build-tree/i386-libc/iconv/strtab.o
/home/edwin/glibc-2.7/build-tree/i386-libc/iconv/xmalloc.o
/home/edwin/glibc-2.7/build-tree/i386-libc/iconv/hash-string.o 
-Wl,-rpath-link=/home/edwin/glibc-2.7/build-tree/i386-libc:/home/edwin/glibc-2.7/build-tree/i386-libc/math:/home/edwin/glibc-2.7/build-tree/i386-libc/elf:/home/edwin/glibc-2.7/build-tree/i386-libc/dlfcn:/home/edwin/glibc-2.7/build-tree/i386-libc/nss:/home/edwin/glibc-2.7/build-tree/i386-libc/nis:/home/edwin/glibc-2.7/build-tree/i386-libc/rt:/home/edwin/glibc-2.7/build-tree/i386-libc/resolv:/home/edwin/glibc-2.7/build-tree/i386-libc/crypt:/home/edwin/glibc-2.7/build-tree/i386-libc/nptl
/home/edwin/glibc-2.7/build-tree/i386-libc/libc.so.6
/home/edwin/glibc-2.7/build-tree/i386-libc/libc_nonshared.a -lgcc
-Wl,--as-needed -lgcc_s  -Wl,--no-as-needed
`/home/edwin/llvm/install/bin/llvm-gcc --print-file-name=crtend.o`
/home/edwin/glibc-2.7/build-tree/i386-libc/csu/crtn.o
/home/edwin/glibc-2.7/build-tree/i386-libc/csu/crtn.o: In function `dummy':
/home/edwin/glibc-2.7/build-tree/i386-libc/csu/crtn.S:15: multiple definition
of `dummy'
/home/edwin/glibc-2.7/build-tree/i386-libc/csu/crti.o:/home/edwin/glibc-2.7/build-tree/i386-libc/csu/crti.S:36:
first defined here
/home/edwin/glibc-2.7/build-tree/i386-libc/csu/crtn.o: In function `_init':
/home/edwin/glibc-2.7/build-tree/i386-libc/csu/crtn.S:41: multiple definition
of `_init'
/home/edwin/glibc-2.7/build-tree/i386-libc/csu/crti.o:/home/edwin/glibc-2.7/build-tree/i386-libc/csu/crti.S:88:
first defined here
/home/edwin/glibc-2.7/build-tree/i386-libc/csu/crtn.o: In function `_fini':
/home/edwin/glibc-2.7/build-tree/i386-libc/csu/crtn.S:100: multiple definition
of `_fini'
/home/edwin/glibc-2.7/build-tree/i386-libc/csu/crti.o:/home/edwin/glibc-2.7/build-tree/i386-libc/csu/crti.S:152:
first defined here
/home/edwin/glibc-2.7/build-tree/i386-libc/csu/crti.o: In function `_fini':
(.fini+0x14): undefined reference to `i_am_not_a_leaf'
/home/edwin/glibc-2.7/build-tree/i386-libc/csu/crtn.o: In function `_fini':
(.fini+0x27): undefined reference to `i_am_not_a_leaf'
/home/edwin/glibc-2.7/build-tree/i386-libc/csu/crtn.o: In function `_fini':
(.fini+0x2c): undefined reference to `i_am_not_a_leaf'
collect2: ld returned 1 exit status

I will attach initfini.c, and the initfini.s, crti.S, crtn.S generated by gcc
and llvm.

At a first glance it looks like inline assembly comments are emitted at the
wrong place (too early):

csu/initfini.s is the gcc one, ../i386-libc/csu/initfini.s is llvm's.

--- csu/initfini.s      2008-03-12 17:36:26.837217313 +0200
+++ ../i386-libc/csu/initfini.s 2008-03-12 17:12:39.480693562 +0200
@@ -1,36 +1,57 @@
-       .file   "initfini.c"
-#APP
+# Start of file scope inline assembly

 #include "defs.h"

 /*@HEADER_ENDS*/

 /*@TESTS_BEGIN*/
-#NO_APP
+
+/*@TESTS_END*/
+
+/*@_init_PROLOG_BEGINS*/
+.section .init
+END_INIT
+
+/*@_init_EPILOG_ENDS*/
+
+/*@_fini_PROLOG_BEGINS*/
+.section .fini
+END_FINI
+
+/*@_fini_EPILOG_ENDS*/
+
+/*@TRAILER_BEGINS*/
+# End of file scope inline assembly
+
+
        .text
-       .p2align 2,,3
+       .align  16
 .globl dummy
        .type   dummy, @function
 dummy:
        pushl   %ebp
        movl    %esp, %ebp
-       subl    $8, %esp
+       pushl   %ebx
+       subl    $4, %esp
+       call    .Lllvm$1.$piclabel
+.Lllvm$1.$piclabel:
+       popl    %ebx
+       addl    $_GLOBAL_OFFSET_TABLE_ + [.-.Lllvm$1.$piclabel], %ebx
        movl    8(%ebp), %eax
        testl   %eax, %eax
-       je      .L4
+       je      .LBB1_2 # UnifiedReturnBlock
+.LBB1_1:       # bb
        call    *%eax
-.L4:
-       leave
+.LBB1_2:       # UnifiedReturnBlock
+       addl    $4, %esp
+       popl    %ebx
+       popl    %ebp
        ret
-#APP
+       .size   dummy, .-dummy

-/*@TESTS_END*/

-/*@_init_PROLOG_BEGINS*/
        .section .init
-#NO_APP
-       .section        .init,"ax", at progbits
-       .p2align 2,,3
+       .align  16
 .globl _init
        .type   _init, @function
 _init:
@@ -38,38 +59,41 @@
        movl    %esp, %ebp
        pushl   %ebx
        subl    $4, %esp
-       call    .L10
-.L10:
+       call    .Lllvm$2.$piclabel
+.Lllvm$2.$piclabel:
        popl    %ebx
-       addl    $_GLOBAL_OFFSET_TABLE_+[.-.L10], %ebx
-       movl    __gmon_start__ at GOT(%ebx), %edx
-       testl   %edx, %edx
-       je      .L7
+       addl    $_GLOBAL_OFFSET_TABLE_ + [.-.Lllvm$2.$piclabel], %ebx
+       cmpl    $0, __gmon_start__ at GOT(%ebx)
+       je      .LBB2_2 # bb4
+.LBB2_1:       # bb
        call    __gmon_start__ at PLT
-.L7:
+.LBB2_2:       # bb4
 #APP
        ALIGN
+       #NO_APP
+       #APP
        END_INIT
+       #NO_APP
+       #APP

 /*@_init_PROLOG_ENDS*/
+       #NO_APP
+       #APP

 /*@_init_EPILOG_BEGINS*/
+       #NO_APP
+       #APP
        .section .init
 #NO_APP
-       popl    %eax
+       addl    $4, %esp
        popl    %ebx
-       leave
+       popl    %ebp
        ret
-#APP
-       END_INIT
+       .size   _init, .-_init

-/*@_init_EPILOG_ENDS*/

-/*@_fini_PROLOG_BEGINS*/
        .section .fini
-#NO_APP
-       .section        .fini,"ax", at progbits
-       .p2align 2,,3
+       .align  16
 .globl _fini
        .type   _fini, @function
 _fini:
@@ -77,13 +101,17 @@
        movl    %esp, %ebp
        pushl   %ebx
        subl    $4, %esp
-       call    .L13
-.L13:
+       call    .Lllvm$3.$piclabel
+.Lllvm$3.$piclabel:
        popl    %ebx
-       addl    $_GLOBAL_OFFSET_TABLE_+[.-.L13], %ebx
+       addl    $_GLOBAL_OFFSET_TABLE_ + [.-.Lllvm$3.$piclabel], %ebx
 #APP
        ALIGN
+       #NO_APP
+       #APP
        END_FINI
+       #NO_APP
+       #APP

 /*@_fini_PROLOG_ENDS*/
 #NO_APP
@@ -91,18 +119,15 @@
 #APP

 /*@_fini_EPILOG_BEGINS*/
+       #NO_APP
+       #APP
        .section .fini
 #NO_APP
-       popl    %ecx
+       addl    $4, %esp
        popl    %ebx
-       leave
+       popl    %ebp
        ret
-#APP
-       END_FINI
-       
-/*@_fini_EPILOG_ENDS*/
-       
-/*@TRAILER_BEGINS*/
+       .size   _fini, .-_fini
        .weak   __gmon_start__
-       .ident  "GCC: (GNU) 4.2.3 (Debian 4.2.3-2)"
-       .section        .note.GNU-stack,"", at progbits
+
+       .ident  "GCC: (GNU) 4.2.1 (Based on Apple Inc. build 5546) (LLVM
build)"


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