I had some doubts about hex formats(assembler output) and linkers:
1.- So, I disassembly a raw binary(no ELF, PE, etc... headers) X64 assembly code and i got that result:
0: 66 89 c8 mov ax,cx
3: e8 00 00 00 00 call 8 <gh>
0000000000000008 <gh>:
8: 66 89 c2 mov dx,ax
I understand how Byte Offset works('66' is the byte ID 0, '89' is 1, 'c8' is 2 and on 3 the call instruction starts(that is why '3:' is there)) but, by that logic, shouldn't 'call gh' be translated to 'e8 00 00 00 00 00 00 00 08' instead of 'e8 00 00 00 00' since the byte offset of the first instruction of gh, which is 'mov dx, ax' is 8 and the output is 64 bits?
2.- Using the example of above, if endianness is little end., how the assembler would swap the bytes, by each instruction? Like:
Original, no endiannes
{
66 89 c8
e8 00 00 00 00(in case that would be correct and i'm wrong in the question 1.-)
66 89 c2
}
to
{
c8 89 66
00 00 00 00 e8
c2 89 66
}
3.- And then, the big end. would be like the original, without endiannes, code of the question 2.-?
4.- Suppose that i mark gh as .globl, then, would the assembler create a map table file where gh is in 'e8 00 00 00 00'(again, in case that would be correct and i'm wrong in question 1.-), and linker will look into such map file, and if another object file calls gh, the linker will then translate call gh as either 'e8 00 00 00 00'?