diff options
author | Mark Wielaard <mark@klomp.org> | 2018-11-09 08:18:22 +0000 |
---|---|---|
committer | Mark Wielaard <mark@klomp.org> | 2018-11-09 17:34:30 +0100 |
commit | 4789e0fb92b03c3d8de548489c871d17f8f35cd0 (patch) | |
tree | 12f4335f80e2a870c52b2819f26eb0025b70d05c /libelf | |
parent | 1628254ba2157ac2b78fc9e103fe0b16fa288a26 (diff) | |
download | elfutils-4789e0fb92b03c3d8de548489c871d17f8f35cd0.tar.gz |
libelf: Explicitly update section data after (de)compression.
We need to explictly trigger a section data reload after updating the
ELF section rawdata to make sure it gets written out to disk on an
elf_update. Doing this showed one bug/inefficiently when the underlying
file has a different endianness. In that case for debug sections we
would convert by allocating a new buffer and just copying over the
raw data into a new buffer. This is not really necessary and would
hide any relocations done on the rawdata by libdwfl.
Added a couple of new ppc64 big endian testfiles that show the issue.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Diffstat (limited to 'libelf')
-rw-r--r-- | libelf/ChangeLog | 7 | ||||
-rw-r--r-- | libelf/elf_compress.c | 6 | ||||
-rw-r--r-- | libelf/elf_getdata.c | 3 |
3 files changed, 15 insertions, 1 deletions
diff --git a/libelf/ChangeLog b/libelf/ChangeLog index af565036..53da9a65 100644 --- a/libelf/ChangeLog +++ b/libelf/ChangeLog @@ -1,3 +1,10 @@ +2018-11-09 Mark Wielaard <mark@klomp.org> + + * elf_compress.c (__libelf_reset_rawdata): Make rawdata change + explicit by calling __libelf_set_data_list. + * elf_getdata.c (convert_data): Don't convert if type is ELF_T_BYTE + even if endianness is different. + 2018-10-18 Mark Wielaard <mark@klomp.org> * libelf.h (Elf_Type): Add ELF_T_NHDR8. diff --git a/libelf/elf_compress.c b/libelf/elf_compress.c index fd412e8a..d96245df 100644 --- a/libelf/elf_compress.c +++ b/libelf/elf_compress.c @@ -326,6 +326,12 @@ __libelf_reset_rawdata (Elf_Scn *scn, void *buf, size_t size, size_t align, scn->rawdata_base = buf; scn->flags |= ELF_F_MALLOCED; + + /* Pretend we (tried to) read the data from the file and setup the + data (might have to convert the Chdr to native format). */ + scn->data_read = 1; + scn->flags |= ELF_F_FILEDATA; + __libelf_set_data_list_rdlock (scn, 1); } int diff --git a/libelf/elf_getdata.c b/libelf/elf_getdata.c index 4f80aaf2..2043bba2 100644 --- a/libelf/elf_getdata.c +++ b/libelf/elf_getdata.c @@ -146,7 +146,8 @@ convert_data (Elf_Scn *scn, int version __attribute__ ((unused)), int eclass, { const size_t align = __libelf_type_align (eclass, type); - if (data == MY_ELFDATA) + /* Do we need to convert the data and/or adjust for alignment? */ + if (data == MY_ELFDATA || type == ELF_T_BYTE) { if (((((size_t) (char *) scn->rawdata_base)) & (align - 1)) == 0) /* No need to copy, we can use the raw data. */ |