[cfe-dev] clang++ linker issues on Ubuntu AMD64.

Lang Hames lhames at gmail.com
Wed Jan 5 00:58:17 PST 2011


Further details:

The assembly output from "int main() {}", compiled with "clang -S -o empty
empty.c" is

    .file   "empty.c"
    .text
    .globl  ":main"
    .align  16, 0x90
":main":                                # @main
.Leh_func_begin0:
# BB#0:                                 # %entry
    pushq   %rbp
.Ltmp0:
    movq    %rsp, %rbp
.Ltmp1:
    movl    $0, %eax
    popq    %rbp
    ret
.Leh_func_end0:

    .section    .eh_frame,"a", at progbits
.LEH_frame0:
.Lsection_eh_frame0:
.Leh_frame_common0:
.Lset0 = .Leh_frame_common_end0-.Leh_frame_common_begin0 # Length of Common
Information Entry
    .long   .Lset0
.Leh_frame_common_begin0:
    .long   0                       # CIE Identifier Tag
    .byte   1                       # DW_CIE_VERSION
    .asciz   "zR"                   # CIE Augmentation
    .byte   1                       # CIE Code Alignment Factor
    .byte   120                     # CIE Data Alignment Factor
    .byte   16                      # CIE Return Address Column
    .byte   1                       # Augmentation Size
    .byte   3                       # FDE Encoding = udata4
    .byte   12                      # DW_CFA_def_cfa
    .byte   7                       # Register
    .byte   8                       # Offset
    .byte   144                     # DW_CFA_offset + Reg (16)
    .byte   1                       # Offset
    .align  8
.Leh_frame_common_end0:
".L:main.eh":
.Lset1 = .Leh_frame_end0-.Leh_frame_begin0 # Length of Frame Information
Entry
    .long   .Lset1
.Leh_frame_begin0:
.Lset2 = .Leh_frame_begin0-.Leh_frame_common0 # FDE CIE offset
    .long   .Lset2
    .long   .Leh_func_begin0        # FDE initial location
.Lset3 = .Leh_func_end0-.Leh_func_begin0 # FDE address range
    .long   .Lset3
    .byte   0                       # Augmentation size
    .byte   4                       # DW_CFA_advance_loc4
.Lset4 = .Ltmp0-.Leh_func_begin0
    .long   .Lset4
    .byte   14                      # DW_CFA_def_cfa_offset
    .byte   16                      # Offset
    .byte   134                     # DW_CFA_offset + Reg (6)
    .byte   2                       # Offset
    .byte   4                       # DW_CFA_advance_loc4
.Lset5 = .Ltmp1-.Ltmp0
    .long   .Lset5
    .byte   13                      # DW_CFA_def_cfa_register
    .byte   6                       # Register
    .align  8
.Leh_frame_end0:


    .section    .note.GNU-stack,"", at progbits

It's pretty clear the colon is being prepended in there, I'm just curious as
to why?

Ismail - do you see the same output on your Linux AMD64 system?

- Lang.

2011/1/5 Lang Hames <lhames at gmail.com>

> Hi Török,
>
> I should have been more clear on this detail too: My "empty" file contained
> an empty main function, rather than being completely empty. So the issue
> with the "missing" main is due to the main symbol being named ":main"
> instead of "main".
>
> - Lang.
>
> 2011/1/5 Török Edwin <edwintorok at gmail.com>
>
>> On 2011-01-05 10:19, İsmail Dönmez wrote:
>>
>> > Hi;
>> >
>> > On Wed, Jan 5, 2011 at 10:16 AM, Lang Hames <lhames at gmail.com> wrote:
>> >
>> >> Specifically I was running with r122866, which was ToT as of earlier
>> today.
>> >> Updating to r122869, the current ToT, does not fix this issue, and (if
>> I
>> >> recall correctly) I saw the same issue when I checked clang out on a
>> >> different AMD64 Ubuntu box a week or so back. Both were Debug+Asserts
>> >> builds.
>> >>
>> >
>> > I am also on x86-64 so this might be a Ubuntu specific problem.
>>
>> I think this depends on your version of binutils, I get the same on
>> Debian with gcc on empty file. Ignore the invalid symbol index, the
>> problem is the missing 'main' function :)
>>
>> $ gcc empty.c
>> /usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 0
>> has invalid symbol index 11
>> /usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 1
>> has invalid symbol index 12
>> /usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 2
>> has invalid symbol index 2
>> /usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 3
>> has invalid symbol index 2
>> /usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 4
>> has invalid symbol index 11
>> /usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 5
>> has invalid symbol index 13
>> /usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 6
>> has invalid symbol index 13
>> /usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 7
>> has invalid symbol index 13
>> /usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 8
>> has invalid symbol index 2
>> /usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 9
>> has invalid symbol index 2
>> /usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 10
>> has invalid symbol index 12
>> /usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 11
>> has invalid symbol index 13
>> /usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 12
>> has invalid symbol index 13
>> /usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 13
>> has invalid symbol index 13
>> /usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 14
>> has invalid symbol index 13
>> /usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 15
>> has invalid symbol index 13
>> /usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 16
>> has invalid symbol index 13
>> /usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 17
>> has invalid symbol index 13
>> /usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 18
>> has invalid symbol index 13
>> /usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 19
>> has invalid symbol index 13
>> /usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 20
>> has invalid symbol index 20
>> /usr/lib/gcc/x86_64-linux-gnu/4.4.5/../../../../lib/crt1.o: In function
>> `_start':
>> (.text+0x20): undefined reference to `main'
>> collect2: ld returned 1 exit status
>>
>>
>>
>> >
>> > Regards,
>> > ismail
>> >
>> >
>> >
>> >
>> > _______________________________________________
>> > cfe-dev mailing list
>> > cfe-dev at cs.uiuc.edu
>> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>>
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110105/8d46826e/attachment.html>


More information about the cfe-dev mailing list