0

An application binary is loaded into RAM, which got compiled using GCC

Does this binary get virtual address (VA) starting from 0x0 or some other value?

(When i check the application binary, i couldn't see any VA in application)

Girish
  • 31
  • 4
  • Which one of the [dozens of possible meanings for the acronym VA](https://www.acronymfinder.com/VA.html) are you referring to? At least *attempt* to explain what it is you are asking about. – NightOwl888 Apr 09 '18 at 13:05
  • It is pretty clear that VA means virtual address from the tags. However, these are assigned by an OS or at least code that manipulates the MMU. This is different depending on the OS, which no details are given. 'linker' is an interesting tags as 'loaders' are actually what would be assigning this. Generally an application is free to use all of the address space from say 0-1GB. A loader will map shared libraries and other features. I agree with NightOwl's sentiment that the question definitely needs work. – artless noise Apr 09 '18 at 14:12
  • Sorry for that NightOwl888. Corrected it. – Girish Apr 09 '18 at 18:30
  • It could be either runtime or compile time; it depends on the OS. It is simplest to be at compile time as the generated code can be more optimal locally. However, PC relative or data address relative code can be produced that lets the OS/loader relocate the code at run time. 99% of the code maybe PC-relative with a few fix-ups that are absolute, etc. It can also be both. The run-time is more optimal for the system as shared libraries can more easily be shared if you can move things around. This may be more optimal globally. Ie, malloc alway in cache, etc. – artless noise Apr 11 '18 at 16:41

1 Answers1

2

I read many articles and found an answer, which could address some of my questions.

GCC uses ELF format to create application binary. If you do "readelf -a app_binary", then it shows the entry point address of the application.

Application compiled using GCC, uses a starting virtual address 0x400000 in 64-bit and 0x804800 in 32-bit systems.

So, if we try access 0x0-0x3fffff, then segmentation fault will be seen. Since that virtual memory is not defined.

Please correct my answer, if it has any mistakes. :-)

Girish
  • 31
  • 4