Indeed ld does link it. The reason I am using llvm-ld, is for its unique functionality. I intend to link to object files together (created by cling), and link them with llvm-ld. The main feature that I am currently interested in is the ability to have "inline functions" between two object files. This was basically impossible with gcc. Is there any way to make the raw binary with llvm? Thank you, Ven Török Edwin wrote:> > > An example with clang: > $ clang -nostartfiles -c x.c -o x.o > $ ld -o x x.o --oformat binary > > Or to get a 32-bit one: > $ /llvm-git/obj/Release/bin/clang -nostartfiles -c x.c -o x.o -m32 > $ ld -o x1 x.o --oformat binary -melf_i386 > > This one is indeed 5 bytes long. > > Best regards, > --Edwin > >-- View this message in context: http://old.nabble.com/Compiling-a-raw-binary-with-llvm-clang-tp26834182p26834869.html Sent from the LLVM - Dev mailing list archive at Nabble.com.
On Thu, Dec 17, 2009 at 1:00 PM, LiteHacker <vilmer88 at gmail.com> wrote:> > Indeed ld does link it. The reason I am using llvm-ld, is for its unique > functionality. > I intend to link to object files together (created by cling), and link them > with llvm-ld. > The main feature that I am currently interested in is the ability to have > "inline functions" between two object files. This was basically impossible > with gcc. > Is there any way to make the raw binary with llvm?Take the .bc file produced by llvm-ld, compile it to assembly with llc, then use the same procedure you were originally using. -Eli
$ clang -ffunction-sections -fdata-sections -Os -nostartfiles -c -o hello.o hello.c $ clang -ffunction-sections -fdata-sections -Os -nostartfiles -c -o test.o test.c $ llvm-ld -s -o hello2 hello.o $ llc hello2.bc -o hello3 $ ld -o hello_B hello3 --oformat binary ld:hello3: file format not recognized; treating as linker script ld:hello3:1: syntax error I am guessing that is what you meant by the "then use the same procedure you were originally using." right? Sorry for the hasle. Thank you for your help, Ven Eli Friedman-2 wrote:> > Take the .bc file produced by llvm-ld, compile it to assembly with > llc, then use the same procedure you were originally using. > > -Eli >-- View this message in context: http://old.nabble.com/Compiling-a-raw-binary-with-llvm-clang-tp26834182p26838687.html Sent from the LLVM - Dev mailing list archive at Nabble.com.
LiteHacker wrote:> > Indeed ld does link it. The reason I am using llvm-ld, is for its unique > functionality. > I intend to link to object files together (created by cling), and link them > with llvm-ld. > The main feature that I am currently interested in is the ability to have > "inline functions" between two object files. This was basically impossible > with gcc. > Is there any way to make the raw binary with llvm?Use llvm-ld -link-as-library to perform many .bc files -> single .bc file with link-time optimization applied. The use llc to turn a single .bc files to a .s (assembly) file which gcc can in turn handle. Nick> Thank you, > Ven > > > Török Edwin wrote: >> >> >> An example with clang: >> $ clang -nostartfiles -c x.c -o x.o >> $ ld -o x x.o --oformat binary >> >> Or to get a 32-bit one: >> $ /llvm-git/obj/Release/bin/clang -nostartfiles -c x.c -o x.o -m32 >> $ ld -o x1 x.o --oformat binary -melf_i386 >> >> This one is indeed 5 bytes long. >> >> Best regards, >> --Edwin >> >>