I'm confused by the following text at page 307:
When the variable is declared as global with its size and type (:data), it will live in the .data section of the executable file rather than the library! Because of this, you will always have to access it through GOT, even in the same file.
Is this really true? Lets modify ex2-main.asm like this:
extern _GLOBAL_OFFSET_TABLE_
global _start
extern sofun
global msg:data (msg.end - msg)
section .rodata
msg: db "SO function called -- message is stored in 'main'", 10
.end:
section .text
_start:
call sofun wrt ..plt
mov rax, 1
mov rdi, 1
mov rsi, msg ; No need to access via GOT.
mov rdx, 50
syscall
mov rdi, 0
mov rax, 60
syscall
Here we are accessing msg directly without GOT and things seem to work fine (the string is printed twice).
I'm confused by the following text at page 307:
Is this really true? Lets modify
ex2-main.asmlike this:Here we are accessing
msgdirectly without GOT and things seem to work fine (the string is printed twice).