'Is this defining the struct pointer address?

I am a bit lost in the following piece of code. What does it mean? Define the the Elf pointer start position?

#define ELFHDR ((struct Elf *) 0x10000)


After reading some answers below, I realize my question is not clear enough. I am not sure what this code mean?

((struct Elf *) 0x10000)

The Macro is used in the function:

readseg((uint32_t) ELFHDR, SECTSIZE*8, 0);

c


Solution 1:[1]

It is defining a macro ELFHDR to be a pointer to address 0x10000. Clearly the author of the code knows the ELF header is there, but that's not what sets it. It is still set in the linker scripts.

Since this is set right (and typically it is right...), accessing ELFHDR results in reading the executable's own ELF header.

Solution 2:[2]

After I read this thread, I realize there are two ways to define a pointer:

int *a

or

int* a

This article explain it very well.

So the macro means that it defines a pointer with the ELF struct type which starts its virtual memory address at 0x10000.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Joshua
Solution 2 Joshua