What am I doing wrong here? $ echo 'int foo() { return 42; }' | i386-elf-gcc -c -o foo.o -x c - -fPIC $ i386-elf-gcc -shared -o http://libfoo.so foo.o This gives a warning about not finding _start and produces an executable not a shared library.
-
Show this thread
-
Replying to @stevecheckoway
What does -shared even mean for "i386-elf" (bare metal?) target?
1 reply 0 retweets 0 likes -
Replying to @RichFelker
I assumed it meant to produce a ET_DYN file rather than ET_EXEC. i386-elf-ld -shared did precisely that. But maybe gcc figures it's nonsensical and so doesn't pass -shared on? It looks like passing -Wl,-shared -shared to gcc does the right thing. *shrug*
1 reply 0 retweets 0 likes -
Replying to @stevecheckoway
I'm guessing the bare metal targets lack specfiles for dynamic linking configuration.
1 reply 0 retweets 0 likes -
Replying to @RichFelker
That makes sense. I probably should have just used a VM rather than a cross compiler since all I really wanted was to look at some -fno-pic shared objects with run-time relocations which I hadn't even realized was supported before tonight.
2 replies 0 retweets 0 likes -
Replying to @stevecheckoway
The extent to which it's supported varies by arch. For x86_64 it likely won't work without compiling for huge model or whatever.
1 reply 0 retweets 0 likes
And in musl it's pretty much entirely unsupported on archs except on 32-bit x86 for historical reasons. Not sure about glibc on non-x86 archs.
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.