I have tested binutils 2.22, built for target arm-eabi. If objcopy or strip is applied to an ELF executable which has a LOAD segment in the program header, but none of the sections refer to it, the virtual address of the segment is set to zero. This behavior is incorrect, as the virtual address is not supposed to be used like this according to the ELF standard. If the segment is to be ignored, its type should be set to NULL or the segment should be discarded altogether, but I prefer that the segment should just be preserved as is. This behavior is probably caused by assign_file_positions_for_load_sections in elf.c: if (m->count == 0) p->p_vaddr = 0; else p->p_vaddr = m->sections[0]->vma - m->p_vaddr_offset;
This problem is serious, since the Linux kernel refuses to execute an ELF executable with such a segment. I have attached a sample file that exhibits this behavior.
hello
Description: Binary data
signature.asc
Description: OpenPGP digital signature
_______________________________________________ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils