summaryrefslogtreecommitdiffstats
path: root/rtemstoolkit/elftoolchain/libelf/gelf_move.c
diff options
context:
space:
mode:
Diffstat (limited to 'rtemstoolkit/elftoolchain/libelf/gelf_move.c')
-rw-r--r--rtemstoolkit/elftoolchain/libelf/gelf_move.c39
1 files changed, 24 insertions, 15 deletions
diff --git a/rtemstoolkit/elftoolchain/libelf/gelf_move.c b/rtemstoolkit/elftoolchain/libelf/gelf_move.c
index 753aba9..2ec8f25 100644
--- a/rtemstoolkit/elftoolchain/libelf/gelf_move.c
+++ b/rtemstoolkit/elftoolchain/libelf/gelf_move.c
@@ -24,25 +24,28 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-
#include <assert.h>
#include <gelf.h>
+#include <limits.h>
+#include <stdint.h>
#include "_libelf.h"
-LIBELF_VCSID("$Id: gelf_move.c 1166 2010-09-04 00:54:36Z jkoshy $");
+ELFTC_VCSID("$Id: gelf_move.c 3177 2015-03-30 18:19:41Z emaste $");
GElf_Move *
-gelf_getmove(Elf_Data *d, int ndx, GElf_Move *dst)
+gelf_getmove(Elf_Data *ed, int ndx, GElf_Move *dst)
{
int ec;
Elf *e;
+ size_t msz;
Elf_Scn *scn;
+ uint32_t sh_type;
Elf32_Move *move32;
Elf64_Move *move64;
- size_t msz;
- uint32_t sh_type;
+ struct _Libelf_Data *d;
+
+ d = (struct _Libelf_Data *) ed;
if (d == NULL || ndx < 0 || dst == NULL ||
(scn = d->d_scn) == NULL ||
@@ -67,15 +70,16 @@ gelf_getmove(Elf_Data *d, int ndx, GElf_Move *dst)
msz = _libelf_msize(ELF_T_MOVE, ec, e->e_version);
assert(msz > 0);
+ assert(ndx >= 0);
- if (msz * ndx >= d->d_size) {
+ if (msz * (size_t) ndx >= d->d_data.d_size) {
LIBELF_SET_ERROR(ARGUMENT, 0);
return (NULL);
}
if (ec == ELFCLASS32) {
- move32 = (Elf32_Move *) d->d_buf + ndx;
+ move32 = (Elf32_Move *) d->d_data.d_buf + ndx;
dst->m_value = move32->m_value;
dst->m_info = (Elf64_Xword) move32->m_info;
@@ -84,7 +88,7 @@ gelf_getmove(Elf_Data *d, int ndx, GElf_Move *dst)
dst->m_stride = move32->m_stride;
} else {
- move64 = (Elf64_Move *) d->d_buf + ndx;
+ move64 = (Elf64_Move *) d->d_data.d_buf + ndx;
*dst = *move64;
}
@@ -93,15 +97,18 @@ gelf_getmove(Elf_Data *d, int ndx, GElf_Move *dst)
}
int
-gelf_update_move(Elf_Data *d, int ndx, GElf_Move *gm)
+gelf_update_move(Elf_Data *ed, int ndx, GElf_Move *gm)
{
int ec;
Elf *e;
+ size_t msz;
Elf_Scn *scn;
+ uint32_t sh_type;
Elf32_Move *move32;
Elf64_Move *move64;
- size_t msz;
- uint32_t sh_type;
+ struct _Libelf_Data *d;
+
+ d = (struct _Libelf_Data *) ed;
if (d == NULL || ndx < 0 || gm == NULL ||
(scn = d->d_scn) == NULL ||
@@ -124,15 +131,17 @@ gelf_update_move(Elf_Data *d, int ndx, GElf_Move *gm)
}
msz = _libelf_msize(ELF_T_MOVE, ec, e->e_version);
+
assert(msz > 0);
+ assert(ndx >= 0);
- if (msz * ndx >= d->d_size) {
+ if (msz * (size_t) ndx >= d->d_data.d_size) {
LIBELF_SET_ERROR(ARGUMENT, 0);
return (0);
}
if (ec == ELFCLASS32) {
- move32 = (Elf32_Move *) d->d_buf + ndx;
+ move32 = (Elf32_Move *) d->d_data.d_buf + ndx;
move32->m_value = gm->m_value;
LIBELF_COPY_U32(move32, gm, m_info);
@@ -141,7 +150,7 @@ gelf_update_move(Elf_Data *d, int ndx, GElf_Move *gm)
move32->m_stride = gm->m_stride;
} else {
- move64 = (Elf64_Move *) d->d_buf + ndx;
+ move64 = (Elf64_Move *) d->d_data.d_buf + ndx;
*move64 = *gm;
}