I think "call" instruction is kind of "jump" instruction. "jump" instruction have the address where to go. And "call" instruction either should have a target address. But when I disassemble the binary, "call" instruction only have a lable of target function. Then, how do they know where to go? In other words, where can I found the target address of each function? x86, ARM whatever.
-
_"But when I disassemble the binary, "call" instruction only have a lable of target function"_ That's something the disassembler does for you to make the disassembly easier to read. That actual machine code sequence for the `call` instruction will contain the target address (which can be relative or absolute). – Michael Apr 01 '15 at 15:06
-
You should see no difference disassembling a jump or a call. – Jester Apr 01 '15 at 15:06
-
1Why not read some book before disassembling and asking such questions – Alexander Zhak Apr 01 '15 at 15:53
-
Are you doing a disassemble of an object file or a program? If a program was built without debug information, then there would be no original labels for the disassembler to use, but it could generate labels, typically the generated label names will include a hex address as part of the name. – rcgldr Apr 01 '15 at 16:50
1 Answers
The addresses in the assembly programming are usually labeled with some symbolic names. And that is true not only for the call instruction but for all other instructions.
There is a reason for this approach - the addresses always depend on where in the memory the program is loaded. Also, some instructions contains not the address itself, but offset, relative to the current address where the program is executed.
On the other hand, the programmer usually doesn't care about the exact value of the address. He only want to know where this address is placed. That is why the symbolic labels are used.
Using symbolic labels with meaningful names improves the readability of the source code and makes the program easy for support and extending.
These symbolic addresses (labels) are translated to numbers during the assembling of the source code to executable binary.
Depending on the executable format, sometimes the translation is partial - only the offsets relative to the beginning of the code are computed. These are so called "relocatable" labels.
Later, when the OS loads the binary to some particular address in the memory, all relocatable addresses are fixed in order to get the proper numeric values for the place the binary is loaded.
This approach is common for the dynamic loaded libraries (DLL) because the loading address is unknown (and different) every time the library is loaded in memory.

- 6,857
- 4
- 31
- 60