[RFC] elf: Add elf checks for main executable
Adhemerval Zanella
adhemerval.zanella@linaro.org
Thu Nov 18 20:02:11 GMT 2021
On 18/11/2021 17:00, Florian Weimer wrote:
> * Adhemerval Zanella:
>
>> +static inline void
>> +_dl_check_ehdr (struct link_map *main_map)
>> +{
>> + ElfW(Ehdr) *ehdr = (void *) main_map->l_map_start;
>> + int err = _dl_elfhdr_check (ehdr);
>> + if (err != DL_ELFHDR_OK)
>> + _dl_fatal_printf ("program loading error: %s\n", _dl_elfhdr_errstr (err));
>> +}
>
> I think you need to iterate through the load segments and see if there
> is one with p_offset == 0 and p_memsz > 0 (the ELF header is smaller
> than a page). That's the one to use for this check. If there is no
> such segment, we have to skip the check.
Hum, should we set the l_map_start as well only if we found such segment?
More information about the Libc-alpha
mailing list