bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Objcopy and strip incorrectly zero ELF virtual address


From: Juho Östman
Subject: Objcopy and strip incorrectly zero ELF virtual address
Date: Tue, 05 Jun 2012 00:46:25 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120430 Thunderbird/12.0.1

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.

Attachment: hello
Description: Binary data

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]