diff options
author | jkoshy <jkoshy@FreeBSD.org> | 2007-11-26 03:09:33 +0000 |
---|---|---|
committer | jkoshy <jkoshy@FreeBSD.org> | 2007-11-26 03:09:33 +0000 |
commit | 6bb7675a71702b9ec524f44be3a8d1e8ae6c8c02 (patch) | |
tree | 7ee081be0a048c2162a215cd19b739af5c5b2529 /lib | |
parent | 2179631991e01f5cac08108afc2fb3758fa63d30 (diff) | |
download | FreeBSD-src-6bb7675a71702b9ec524f44be3a8d1e8ae6c8c02.zip FreeBSD-src-6bb7675a71702b9ec524f44be3a8d1e8ae6c8c02.tar.gz |
- Allow source descriptors with no data to be used as arguments to the
elf{32,64}_xlateto[fm]() translation functions. This change makes our
libelf compatible with other ELF(3) implementations. [1]
- Update manual page to reflect this change.
- Style fixes: wrap a long line.
Submitted by: jb [1]
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libelf/gelf_xlatetof.3 | 6 | ||||
-rw-r--r-- | lib/libelf/libelf_xlate.c | 11 |
2 files changed, 5 insertions, 12 deletions
diff --git a/lib/libelf/gelf_xlatetof.3 b/lib/libelf/gelf_xlatetof.3 index 436fef3..b769930 100644 --- a/lib/libelf/gelf_xlatetof.3 +++ b/lib/libelf/gelf_xlatetof.3 @@ -208,12 +208,6 @@ specified an unsupported type. .It Bq Er ELF_E_DATA The .Ar src -argument had a zero -.Va d_size -field. -.It Bq Er ELF_E_DATA -The -.Ar src argument specified a buffer size that was not an integral multiple of its underlying type. .It Bq Er ELF_E_DATA diff --git a/lib/libelf/libelf_xlate.c b/lib/libelf/libelf_xlate.c index 06ef8d0..362e82d 100644 --- a/lib/libelf/libelf_xlate.c +++ b/lib/libelf/libelf_xlate.c @@ -68,8 +68,7 @@ _libelf_xlate(Elf_Data *dst, const Elf_Data *src, unsigned int encoding, return (NULL); } - if (src->d_buf == NULL || dst->d_buf == NULL || - src->d_size == 0) { + if (src->d_buf == NULL || dst->d_buf == NULL) { LIBELF_SET_ERROR(DATA, 0); return (NULL); } @@ -79,8 +78,8 @@ _libelf_xlate(Elf_Data *dst, const Elf_Data *src, unsigned int encoding, return (NULL); } - if ((fsz = (elfclass == ELFCLASS32 ? elf32_fsize : elf64_fsize)(src->d_type, - (size_t) 1, src->d_version)) == 0) + if ((fsz = (elfclass == ELFCLASS32 ? elf32_fsize : elf64_fsize) + (src->d_type, (size_t) 1, src->d_version)) == 0) return (NULL); msz = _libelf_msize(src->d_type, elfclass, src->d_version); @@ -133,8 +132,8 @@ _libelf_xlate(Elf_Data *dst, const Elf_Data *src, unsigned int encoding, dst->d_type = src->d_type; dst->d_size = dsz; - if (db == sb && encoding == LIBELF_PRIVATE(byteorder) && - fsz == msz) + if (src->d_size == 0 || + (db == sb && encoding == LIBELF_PRIVATE(byteorder) && fsz == msz)) return (dst); /* nothing more to do */ (_libelf_get_translator(src->d_type, direction, elfclass))(dst->d_buf, |