mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-19 13:47:56 +00:00
ldso: check for DYNAMIC segment in ELF files
If the DYNAMIC segment cannot be located the ELF file may be statically linked. In this case an error is raised. Fixes #3000
This commit is contained in:
parent
a8ed11e75b
commit
0cc87d3c85
@ -183,9 +183,13 @@ struct Linker::Elf_file : File
|
||||
*/
|
||||
void loadable_segments(Phdr &result)
|
||||
{
|
||||
bool dynamic = false;
|
||||
for (unsigned i = 0; i < phdr.count; i++) {
|
||||
Elf::Phdr *ph = &phdr.phdr[i];
|
||||
|
||||
if (ph->p_type == PT_DYNAMIC)
|
||||
dynamic = true;
|
||||
|
||||
if (ph->p_type != PT_LOAD)
|
||||
continue;
|
||||
|
||||
@ -196,6 +200,16 @@ struct Linker::Elf_file : File
|
||||
|
||||
result.phdr[result.count++] = *ph;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check for 'DYNAMIC' segment which should be present in all dynamic ELF
|
||||
* files.
|
||||
*/
|
||||
if (!dynamic) {
|
||||
error("LD: ELF without DYNAMIC segment appears to be statically linked ",
|
||||
"(ld=\"no\")");
|
||||
throw Incompatible();
|
||||
}
|
||||
}
|
||||
|
||||
bool is_rx(Elf::Phdr const &ph) {
|
||||
|
Loading…
Reference in New Issue
Block a user