diff options
| author | Ulrich Drepper <[email protected]> | 2008-12-04 05:58:16 +0000 |
|---|---|---|
| committer | Ulrich Drepper <[email protected]> | 2008-12-04 05:58:16 +0000 |
| commit | 02f66452635df3d01f7e57845c3362ab828e3d89 (patch) | |
| tree | 24b5255577524d60a33f79596fa1505379d96901 /libelf/elf32_checksum.c | |
| parent | 593798821113c57fe10f1fdf6593658d99d05ca9 (diff) | |
propagate from branch 'com.redhat.elfutils.roland.pending.libelf-threads' (head fc97c9c202b5d7d7699a3b1d5c53007a2ef37bb1)
to branch 'com.redhat.elfutils' (head 67cccb9bfffc1a7fe3d8d355a2d9b6d0e489ff81)
Diffstat (limited to 'libelf/elf32_checksum.c')
| -rw-r--r-- | libelf/elf32_checksum.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/libelf/elf32_checksum.c b/libelf/elf32_checksum.c index 0e4ab9f7..32b4a02d 100644 --- a/libelf/elf32_checksum.c +++ b/libelf/elf32_checksum.c @@ -105,6 +105,14 @@ elfw2(LIBELFBITS,checksum) (elf) || (ident[EI_DATA] == ELFDATA2MSB && __BYTE_ORDER == __BIG_ENDIAN)); + /* If we don't have native byte order, we will likely need to + convert the data with xlate functions. We do it upfront instead + of relocking mid-iteration. */ + if (!likely (same_byte_order)) + rwlock_wrlock (elf->lock); + else + rwlock_rdlock (elf->lock); + /* Iterate over all sections to find those which are not strippable. */ scn = NULL; while ((scn = INTUSE(elf_nextscn) (elf, scn)) != NULL) @@ -118,7 +126,8 @@ elfw2(LIBELFBITS,checksum) (elf) if (shdr == NULL) { __libelf_seterrno (ELF_E_INVALID_SECTION_HEADER); - return -1l; + result = -1l; + goto out; } if (SECTION_STRIP_P (shdr, @@ -162,17 +171,25 @@ elfw2(LIBELFBITS,checksum) (elf) /* Convert the data to file byte order. */ if (INTUSE(elfw2(LIBELFBITS,xlatetof)) (data, data, ident[EI_DATA]) == NULL) - return -1l; + { + result = -1l; + goto out; + } result = process_block (result, data); /* And convert it back. */ if (INTUSE(elfw2(LIBELFBITS,xlatetom)) (data, data, ident[EI_DATA]) == NULL) - return -1l; + { + result = -1l; + goto out; + } } } + out: + rwlock_unlock (elf->lock); return result; } INTDEF(elfw2(LIBELFBITS,checksum)) |
