Joseph Elcid
Joseph Elcid

Reputation: 877

Constituant of data segments

So, I have this idea and I've searched around to see if its true, but haven't found anything to confirm it yet.
I'm working on an elf parser and I'd like to construct the program's data from the sections.
My idea is that the data segment is made of the information in the .data, .data1, .bss, .ctors and .dtors (.ctors and .dtors for c++ programs) sections; is that correct?
Please provide links for documentation

Upvotes: 1

Views: 91

Answers (1)

Benny
Benny

Reputation: 4321

When loading segments to memory, you must look at the program header table, not at the section header table. Program headers are loader's inputs, whereas section headers are intended for debugging info.

For example, the .data and .bss could be gathered into the same program header, or scattered in two program headers. One or two segments of memory would be allocated. Having one code segment and one memory segment is nothing but mandatory. It depends on how the binary has been linked.

Upvotes: 1

Related Questions