ELF object writing from assembly file

Hi all,

I have implemented AsmParser, CodeEmitter, and ELF object writing.

AsmParser and CodeEmitter are tested and working fine, but I would like to see ELF objects build out of a parsed asm file. Is that possible?

I tried this commands, but it didn’t work corrctly:

llvm-mc -filetype=obj -arch=test file.s -o=a.o

and I think after an obj file is built, I should use this command but I am not sure!

llvm-objdump -arch=test a.o

Cheers,

ES

(corrector) I think for reading obj file it should be:
llvm-readobj -arch=test a.o

I tried this commands, but it didn't work corrctly:

llvm-mc -filetype=obj -arch=test file.s -o=a.o

That looks right to me ("-triple test-elf" might be more robust and
work if you're coding on OS X or Windows).

and I think after an obj file is built, I should use this command but I am
not sure!

llvm-objdump -arch=test a.o

Either llvm-objdump or llvm-readobj will work. llvm-readobj tends to
produce lower level information, while llvm-objdump is more
user-friendly. They ought to mostly work on the generic information
without changes.

If you want "-d" (disassemble) to work, you're going to have to
implement a Disassembler in your target too.

Tim.

Thanks a lot Tim.

I am getting an error which says: “LLVM ERROR: unable to write nop sequence of 0 bytes”

Is there any way that I can print out the Obj code (I mean bitstream representation of the assembly code which is going to be placed in the ELF file), before making any ELF file?

Cheers,

ES

I am getting an error which says: "LLVM ERROR: unable to write nop sequence
of 0 bytes"

Sounds like you need to implement "writeNopData" from the AsmBackend.

Is there any way that I can print out the Obj code (I mean bitstream
representation of the assembly code which is going to be placed in the ELF
file), before making any ELF file?

I think it's only really produced on demand while writing the ELF
file. You might look at the output of "llc -debug", which shows some
of the intermediate data structures, none of them are really just the
instruction bits.

Cheers.

Tim.

Hello Tim,

In the writeNopData, I changed the return value to true, and now everything is fine!

Thanks a lot for your help.

Cheers,

ES