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

Lang Hames lhames at gmail.com
Tue Jan 4 23:03:56 PST 2011


Hi All,

I'm attempting to compile the following function

int main() {}

under Ubuntu 10.10 AMD64 with

clang++ -o empty empty.cpp

and it's yielding

/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
<--- snip (there's about 17 more lines of this...) --->
/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.5.1/../../../../lib/crt1.o: In function
`_start':
(.text+0x20): undefined reference to `main'
clang: error: linker command failed with exit code 1 (use -v to see
invocation)

If I run

clang++ -c -o empty.o empty.cpp
nm empty.o

I see

0000000000000000 T :main

Is that colon the issue? (Object file formats and symbol names are not my
area of expertise). In any case renaming ":main" to "main" with objcopy and
then running ld manually yields a working executable.

So is this an invalid symbol name? A valid but incorrect one? Is there some
flag that clang should be passing to ld to get it to recognise this symbol?
I'd file a bug report, but as you can tell I'm slightly hazy on what the bug
is.

Cheers,
Lang.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110105/9af9b94b/attachment.html>


More information about the cfe-dev mailing list