Reputation: 71
I am trying to learn how ELF files are structured and probably how to make one manually.
I am working on aarch64 Linux OS, the ELF files I am inspecting are of elf64-littleaarch64
format.
Also I try to learn by myself, however I got stuck with some questions...
xxd code
, the first number in each line of the output specifies the address of bytes in the file. But when objdump -D code
, the first number is something like 4000b0
, however corresponds to 000000b0
in xxd
. Why is there a four at the beginning?objdump
, the bytecode is for example 11000a94
, which 'means'
add w20, w20, #2
in assembly. I know, that 11
is the opcode, but what does 000a94
mean? I thought, it should be the parameters, but I am adding the value 2 and can't find the number 2 in it.If you have a good article to read, or can help me explain this, I will be very grateful!
Upvotes: 0
Views: 993
Reputation: 71
Well, I was too fast asking this question, but now, I will answer it too.
40
at the beginning of the addresses in objdump
is the hex representation of the char "@", which means "at" and points to an address, very simple!objdump
code: 11000a94
--> 10001000000000000101010010100
, where it can be divided into [10001][00000000000010][10100][10100]
with [opcode][value][first address][second address]
Both answers are wrong, see the accepted answer. I will still let them here, though
Upvotes: 0
Reputation: 58673
xxd
shows the offset of the bytes within the file on disk. objdump -D
shows (tentatively) the address in memory where those bytes will be loaded when the program is run. It is common for them to differ by a round number. In particular, 0x400000
may correspond to one higher-level page table entry; see Why Linux/gnu linker chose address 0x400000? which is for x86-64 but I think ARM64 is similar (haven't checked). It doesn't have anything to do with the fact that 0x40
is ASCII @
; that's just a coincidence.
Note that if ASLR is in use, the actual memory address will be randomly chosen every time the program is run, and will not match what objdump
shows you, though the difference will still be a multiple of the page size.
Upvotes: 1