▲ | o11c 5 days ago | ||||||||||||||||||||||||||||||||||
I wouldn't call them "same concept" at all. Segments (program headers) are all about the runtime (executables and shared libraries) and are low-cost. Sections are all about development (.o files) and are detailed. Generally there are many sections combined into a single segment, other than special-purpose ones. Unless you are reimplementing ld.so, you almost certainly don't want to touch segments; sections are far easier to work with. Also, normally you just just call `getauxval`, but if needed the type is already named `ElfW(auxv_t)*`. | |||||||||||||||||||||||||||||||||||
▲ | matheusmoreira 5 days ago | parent [-] | ||||||||||||||||||||||||||||||||||
> I wouldn't call them "same concept" at all. They are both metadata about file extents and their memory images. > sections are far easier to work with Yes. They are not, however, loaded into memory by default. Linkers do not generate LOAD segments for section metadata since they are not needed for execution. Thus it's impossible for a program to introspect its own sections without additional logic and I/O to read them into memory. > Also, normally you just just call `getauxval`, but if needed the type is already named `ElfW(auxv_t)*`. True. I didn't use it because it was not available. I wrote my article in the context of a freestanding nolibc program. | |||||||||||||||||||||||||||||||||||
|