+2022-04-01 Mark Wielaard <mark@klomp.org>
+
+ * libelfP.h (struct Elf_Data_Chunk): Add an int64_t offset field.
+ * elf_getdata_rawchunk.c (elf_getdata_rawchunk): Check whether the
+ requested chunk, offset, size and type, was already handed out.
+ Set new Elf_Data_Chunk offset field.
+
2022-03-29 Mark Wielaard <mark@klomp.org>
* gelf_xlate.c (START): Define and use sz variable.
/* Return converted data from raw chunk of ELF file.
Copyright (C) 2007, 2014, 2015 Red Hat, Inc.
+ Copyright (C) 2022 Mark J. Wielaard <mark@klomp.org>
This file is part of elfutils.
This file is free software; you can redistribute it and/or modify
rwlock_rdlock (elf->lock);
+ /* Maybe we already got this chunk? */
+ Elf_Data_Chunk *rawchunks = elf->state.elf.rawchunks;
+ while (rawchunks != NULL)
+ {
+ if ((rawchunks->offset == offset || size == 0)
+ && rawchunks->data.d.d_size == size
+ && rawchunks->data.d.d_type == type)
+ {
+ result = &rawchunks->data.d;
+ goto out;
+ }
+ rawchunks = rawchunks->next;
+ }
+
size_t align = __libelf_type_align (elf->class, type);
if (elf->map_address != NULL)
{
chunk->data.d.d_type = type;
chunk->data.d.d_align = align;
chunk->data.d.d_version = EV_CURRENT;
+ chunk->offset = offset;
rwlock_unlock (elf->lock);
rwlock_wrlock (elf->lock);