| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
| |
Change-Id: I5429f63166f8e7da6b2099157fefc3f590d97719
|
|
|
|
| |
Change-Id: I4b3859757c67e4a505c7e96b27907db47e44d106
|
|
|
|
|
|
|
|
| |
Bug: http://b/25642296
This reverts commit e223eb95c4f3df36a7c24c3b9a4dfdeec06ac15d.
Change-Id: I727eefee8e4edb8d85528999698b82b14855d615
|
|\
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
* git merge 203f0a3
* See all upstream changes since the previous merge
in branch aosp/upstream-master:
git diff 9d1e236..203f0a3
* Android relevant upstream changes:
* Version number changed from 0.164 to 0.165
* libelf now depends on zlib
* Changed version number in generated files:
version.h, config.h
* No change to generated files:
libdw/known-dwarf.h
* Updated libelf/Android.mk:
* added new source files:
gelf_getchdr.c elf{32,64}_getchdr.c elf_compress.c
* added LOCAL_STATIC_LIBRARIES := libz
Change-Id: Ieb306d84ffcaf680ad6e74da28fcc8efbf00592a
|
| |
| |
| |
| |
| |
| |
| | |
* elf_compress.c (__libelf_compress): do_deflate_cleanup
* elf_strptr.c (elf_strptr): get_zdata
Signed-off-by: Chih-Hung Hsieh <chh@google.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Older glibc elf.h might not define the new ELF compression defines and
types. If not just define them in libelf.h directly to make the libelf
headers work on older glibc systems.
Also include a testcase to check the libelf headers build against the
system elf.h.
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=810885
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
elf_strptr indexes into the section data. This is defined as index into
the uncompressed data of the section. If the section is compressed make
sure the uncompressed data is available, but don't really decompress the
section header (elf_getdata will still return compressed data).
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
| |
| |
| |
| | |
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Elf_Data of a compressed section has type ELF_T_CHDR. This type can be
xlated to the file or memory representation. This will make sure the Chdr
is in the correct endianess. The compressed data following the Chdr isn't
translated.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
clang/llvm for aarch64 generates relocation references
to local symbols and that is not supported by Android
dynamic linker.
BUG: 25642296
Change-Id: If99aca50002eef4cce7735c6defef2fcb76f5a9b
|
| |
| |
| |
| |
| |
| |
| | |
* libdwelf, libebl, libelf can compile cleanly with clang now.
* libdw and libdwfl still have some nested functions only compiled by gcc.
Change-Id: Id43585c6d11f521ef0ccebe9cae4db9de436cdc0
|
|\|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
* git merge ae09ca9
* See all upstream changes since the previous merge:
git diff 5eb3e90..ae09ca9
* Android relevant upstream changes:
Move nested functions to file scope:
backends/ia64_retval.c, aarch64_regs.c
libdwfl/frame_unwind.c, dwfl_module.c
* Other upstream changes unrelated to Android:
Make zlib mandatory.
* No changes to the following generated files:
version.h, config.h, libdw/known-dwarf.h
|
| |
| |
| |
| |
| |
| | |
Explicitly link libelf and libdw with -lz.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
|\|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
* git merge 5eb3e90
* Android relevant upstream changes:
Move nested functions to file scope:
libdw/cfi.c, libdwelf, libelf
elf.h: Update from glibc. Add section compression constants and structures.
libelf: use the right size when preading in[0].sh_size
See all upstream changes since the previous merge:
git diff a1e17a2..5eb3e90
* No changes to the following generated files:
version.h, config.h, libdw/known-dwarf.h
|
| |
| |
| |
| | |
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
| |
| |
| |
| | |
Signed-off-by: Jose E. Marchesi <jose.marchesi@oracle.com>
|
| |
| |
| |
| |
| |
| |
| |
| | |
* Move nested functions to file scope
in libelf/elf_begin.c and elf32_updatefile.c
to compile with clang.
Signed-off-by: Chih-Hung Hsieh <chh@google.com>
|
|\|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
* git merge a1e17a2
* Android relevant upstream changes:
version number changed to 0.164
handle ELF with merged strtab/shstrtab
handle missing SHF_INFO_LINK section flags
open64 -> open
loff_t -> int64_t
conditionally include <config.h>
See all upstream changes since the previous merge:
git diff 86ed7f7..a1e17a2
* Manual changes (of generated files) after git merge:
* version.h: new version number 164.
* config.h: new version number 0.164, still keep Android #if __LP64__
* libdw/known-dwarf.h: no change
Change-Id: Ieb1bfed35e76ee3a641499897863679e6d4da096
|
| |
| |
| |
| |
| |
| |
| |
| | |
Some systems don't have loff_t, like FreeBSD where off_t always supports
large files. We need a standardized 64-bit signed type for the public
header, without depending on configuration... OK, just use int64_t.
Signed-off-by: Josh Stone <jistone@redhat.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Don't use posix_fallocate when not using mmap. It is enough to ftruncate
the file to the right size. pwrite will report an error if there is no
disk space left. And on file systems that don't support fallocate it
might duplicate writes in that case. When using posix_fallocate do ignore
most errors. Other libc implementations don't guarantee the call actually
works always and even with glibc there might be an unexpected error from
the fallback code when the file system doesn't support fallocate. That is
pretty nasty since we might get a SIGBUS in that case when writing to the
mmapped memory. But the chance of that happening is very small. And will
normally never happen with glibc. So only report an error when
posix_fallocate reports ENOSPC.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
AC_SYS_LARGEFILE defines _FILE_OFFSET_BITS in config.h if needed for
LFS, and this automatically maps things like open to open64. But quite
a few places used explicit 64-bit names, which won't work on platforms
like FreeBSD where off_t is always 64-bit and there are no foo64 names.
It's better to just trust that AC_SYS_LARGEFILE is doing it correctly.
But we can verify this too, as some file could easily forget to include
config.h. The new tests/run-lfs-symbols.sh checks all build targets
against lfs-symbols (taken from lintian) to make sure everything was
implicitly mapped to 64-bit variants when _FILE_OFFSET_BITS is set.
Signed-off-by: Josh Stone <jistone@redhat.com>
|
|\|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
git merge 86ed7f7
Include upstream changes up to Thu Oct 8 00:16:03 2015.
Previous clang compilation errors about union of VLA
should be fixed with this merge.
* Allocate exact amount of bytes for phdrs and shdrs.
* Do without union of variable length arrays.
* Other changes from upstream, not all used for Android:
AM_SILENT_RULES coverage, sparc check_object_attribute ebl hook,
Use -fPIC in PIC code.
* No change of generated files such as:
./config.h, libdw/known-dwarf.h, ./version.h
Change-Id: Iac63519112c4a92b57344f4a43bf0e9a6c4baa13
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Prepare to compile with clang.
A union like
{ T32 a32[n]; T64 a64[n]; } u;
is expanded to
size_t nbytes = n * MAX(sizeof(T32), sizeof(T64));
void *data = malloc(nbytes);
T32 (*a32)[n] = data;
T64 (*a64)[n] = data;
Signed-off-by: Chih-Hung Hsieh <chh@google.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Note, elfutils does not explicitly enable AM_SILENT_RULES. It's only
available starting from automake 1.11, but starting from automake 1.13
silent rules are always generated, defaulting to verbose. $(AM_V_foo)
additions should be no-ops on systems that don't support silent rules.
To be silent, use "./configure --enable-silent-rules" or "make V=0".
Signed-off-by: Josh Stone <jistone@redhat.com>
|
| |
| |
| |
| |
| |
| |
| | |
This avoids relocation overflows in sparc/sparc64 targets while
linking, where the reachable data using -fpic is only 4kb.
Signed-off-by: Jose E. Marchesi <jose.marchesi@oracle.com>
|
|\|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
* Four libdwfl nested functions were converted to standard C syntax,
to compile with clang/llvm.
* Other upstream changes since SHA d8698e5, see git log for details:
sparc relocation types, update sh_info in unstrip,
strtab/shstrtab string tables in strip and unstrip,
update e_version and e_shentsize in elf_update,
Ukrainian translation.
Change-Id: Ib5871cd3873a8fdf88683c30d95effc7fdc338f5
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
When e_version is EV_NONE we should set it to EV_CURRENT like we do for
the EI_VERSION and like we set EI_DATA to the correct byte order when set
to ELFDATANONE. Likewise we should always set e_shentsize like we do for
e_phentsize, not just when ELF_F_LAYOUT isn't set.
Add a new elfshphehdr testcase to check the above.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
|\|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
git merge d8698e55cbe95e56c3a4cbd67c320048ea4f087a
Include upstream changes up to Wed Sep 23 20:44:06 2015.
Update generated files:
./config.h
./libdw/known-dwarf.h
./version.h
Change-Id: Ica2510edda846659a0c89703aeafe85bd62abab8
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Since we banned old style function definitions GCC is able to diagnose
function definitions that don't match the function declaration:
elf32_getehdr.c:78: error: conflicting types for ‘__elf64_getehdr_wrlock’
libelfP.h:498: note: previous declaration of ‘__elf64_getehdr_wrlock’
This happens on i386 because there internal functions are marked with:
# define internal_function __attribute__ ((regparm (3), stdcall))
Make sure all internal function declarations and definitions are marked
with internal_function.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
| |
| |
| |
| |
| |
| |
| | |
We already require -std=gnu99 and old-style function definitions might
hide some compiler warnings.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Our dl-hash.h implementation originally came from, or was written at the
same time as, the glibc implementation. At some point (around 9 years ago)
they diverged and the elfutils version got an updated copyright header.
The glibc version saw various updates/optimizations. Just treat the file
like we do for elf.h and copy it whenever the glibc version is updated.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
| |
| |
| |
| |
| |
| |
| | |
When something goes wrong during the update make sure to always free any
temporary allocated memory (shdr_data and/or scns).
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
| |
| |
| |
| | |
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
When elf_update.c (write_file) doesn't know the current maximum file length
it might have to reduce the file size. posix_fallocate can only extend the
file. So always call ftruncate before that to set the file size and making
sure the backing store is fully there. Add test cases for checking strip
in place (eu-strip without -o) actually reduces the file size. But only
for non-ET_REL files. We might not be able to strip ET_REL files (except
when they are kernel modules) because they might contain "dangling" symbol
table entries.
https://bugzilla.redhat.com/show_bug.cgi?id=1232206
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
elf_getdata_rawchunk might return an unaligned buffer for the requested
ELF data type. Make sure the data is also correctly aligned when using
an mmapped file. Also add some missing alignments for ELF data types
for __libelf_type_align (the missing types could also make elf_getdata
to return unaligned data).
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The gelf_xlate conversion functions work on properly aligned ELF data
types. If elf_get data needs to do conversion and ! ALLOW_UNALIGNED
and the rawdata_base isn't aligned properly for the section type, then
provide an aligned copy of the data.
Found with --enable-sanitize-undefined in run-test-archive64.sh on x86_64.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
| |
| |
| |
| |
| |
| |
| |
| | |
In get_shnum the check was whether the Elf(32|64)_Ehdr was correctly
aligned, but to access the Shdr directly we need to check whether the
address that points to the Elf(32|64)_Shdr structure is correctly aligned.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
There are various places in the code that check whether mmapped structures
are correctly aligned (or ALLOW_UNALIGNED is set). Some of these checks
are asserts. Like the one in elf(32|64)_getshdr. We should not get into
that part of the code if the shdr scn structure was cached in elf_begin
because it was mmapped in and properly aligned.
These asserts could trigger because in elf_begin.c file_read_elf ()
all alignment checks were combined. So even though only one of the ehdr,
shdr or phdr structures were not properly aligned all structures would be
copied. Also the phdr structure was not even read in elf_begin, so the
alignment check was unnecessary.
This patch splits the alignment checks and reading of ehdr and shdr
structures into separate code paths. It also drops the phdr alignment
checks in elf_begin. Those phdr checks are done in elf(32|64)_getphdr
already.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
| |
| |
| |
| |
| |
| |
| | |
When a copy needs to be made of the shdrs, allocate with malloc and free
after conversion instead of calling alloca.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
| |
| |
| |
| |
| |
| |
| | |
When a copy needs to be made of the phdrs, allocate with malloc and free
after conversion instead of calling alloca.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
| |
| |
| |
| |
| |
| |
| | |
The number of entries in the index can be large, don't use alloca to
read in temporary data, use malloc (which is freed after out).
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
| |
| |
| |
| |
| |
| | |
When size is zero the buffer src and dest buffers might be NULL.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
| |
| |
| |
| |
| |
| |
| | |
When d_size is zero d_buf might be NULL. last_position doesn't need to be
updated in that case.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
| |
| |
| |
| |
| |
| |
| | |
Allocate shdr_data and scns with malloc, not alloca. Free after writing
section headers.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
| |
| |
| |
| |
| |
| |
| | |
Allocate temporary shdr storage with malloc, not alloca. Free after
writing section headers.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
| |
| |
| |
| |
| |
| |
| | |
The number of entries in the index can be large, don't use alloca to
read in temporary data, use malloc (and free after out).
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This fixes an obscure SIGBUS error when using ELF_C_WRITE_MMAP on an ELF
file that needs extending when the underlying file system is (nearly) full.
Use posix_fallocate to make sure the file content is really there. Using
ftruncate might mean the file is extended, but space isn't allocated yet.
This might cause a SIGBUS once we write into the mmapped space and the disk
is full.
Using fallocate might fail on some file systems. posix_fallocate is
required to extend the file and allocate enough space even if the
underlying filesystem would normally return EOPNOTSUPP or the kernel
doesn't implement the fallocate syscall. Also posix_fallocate has been in
glibc since 2.1.94, while support for fallocate was only added in 2.10
and kernel 2.6.23.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
If phnum is zero make sure e_phoff is also zero and not some random value.
That would cause trouble in update_file. This could happen when ELF_F_LAYOUT
is set and the user copied over a ehdr from a bogus ELF file where the phdrs
are unreadable. In that case trying to write out the new ELF image would
crash trying to follow the bogus e_phdr value.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
There were two issues with bogus sh_addralign values. First we would only
check the individual Elf_Data d_align values were powerof2. But not the
actual shdr addralign value. This would cause an issue if the shdr addralign
was bigger than all of the individual d_align values. Then we could write
out a bogus (! powerof2) shdr addralign value for the sections. Secondly
when reading in the Elf_Data we would set the d_align value to the value
of the shdr addralign value. But we would not check it was valid at all.
In practice there are ELF files with incorrect sh_addralign values (they
are a powerof2, but aren't aligned to the ELF image offset). We would try
to fix that up in elf_update by adding extra padding. But this could bloat
the ELF image a lot for large alignment values. So for too large alignments
that are bigger than the offset in the ELF file clamp them to the offset
value. This could lead us to reject to write out the data again when the
offset was not a powerof2. But this will only happen for aligment values
bigger than 64. Which are uncommon in practice.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Creating phdr with more than PN_XNUM phnum requires a valid section zero
shdr to store the extended value. Make sure the shdrs are valid. Also fix
the error when count was too big to store by setting ELF_E_INVALID_INDEX
before failing.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
|