linker - How to get the image base address in the code when compiling with GCC? -


i'm doing embedded programming gcc. how image base address in c code?

p.s. know set-up variable in linker script. there other way achieve without bother modify script?

thanks in advance.

if understand question correctly, don't want explicitly set base address want know base address set part of output.

you can generate map file part of compile passing argument linker. example:

gcc -wall -o hello_world.exe -wl,-map,hello_world.map hello_world.c 

the relevant section being -wl,-map,hello_world.map meaning passing -map option linker , telling generate file hello_world.map.

the resultant output has lot of information in looking section following:

linker script , memory map              0x00400000                __image_base__ = 0x400000             0x00000000                __dll__ = 0x0             0x00400000                ___imagebase = 0x400000             0x00001000                __section_alignment__ = 0x1000             0x00000200                __file_alignment__ = 0x200             0x00000004                __major_os_version__ = 0x4             0x00000000                __minor_os_version__ = 0x0             0x00000001                __major_image_version__ = 0x1             0x00000000                __minor_image_version__ = 0x0             0x00000004                __major_subsystem_version__ = 0x4             0x00000000                __minor_subsystem_version__ = 0x0             0x00000003                __subsystem__ = 0x3             0x00200000                __size_of_stack_reserve__ = 0x200000             0x00001000                __size_of_stack_commit__ = 0x1000             0x00100000                __size_of_heap_reserve__ = 0x100000             0x00001000                __size_of_heap_commit__ = 0x1000             0x00000000                __loader_flags__ = 0x0             0x00008000                __dll_characteristics__ = 0x8000 

the image's base address should visible locations of stack, heap (if have one), , of functions.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -