summaryrefslogtreecommitdiff
path: root/nuttx/arch/x86
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-09-09 16:52:51 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-09-09 16:52:51 -0600
commit0c26b439a6aac1c6e846ca7760226e33811474af (patch)
tree409fc9f4a3fe6964fd2004c4fb5655f5cf2e825d /nuttx/arch/x86
parente3b0a4943f26e317f00e0254a5d6b7503bf7b8fa (diff)
downloadpx4-nuttx-0c26b439a6aac1c6e846ca7760226e33811474af.tar.gz
px4-nuttx-0c26b439a6aac1c6e846ca7760226e33811474af.tar.bz2
px4-nuttx-0c26b439a6aac1c6e846ca7760226e33811474af.zip
ELF relocations. Some relocation types do not have a named symbol associated with them. The design did not account for that case
Diffstat (limited to 'nuttx/arch/x86')
-rw-r--r--nuttx/arch/x86/src/common/up_elf.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/nuttx/arch/x86/src/common/up_elf.c b/nuttx/arch/x86/src/common/up_elf.c
index 7c5772a9b..894f86578 100644
--- a/nuttx/arch/x86/src/common/up_elf.c
+++ b/nuttx/arch/x86/src/common/up_elf.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/x86/src/up_elf.c
*
- * Copyright (C) 2012 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2012, 2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -100,6 +100,10 @@ bool up_checkarch(FAR const Elf32_Ehdr *hdr)
* Input Parameters:
* rel - The relocation type
* sym - The ELF symbol structure containing the fully resolved value.
+ * There are a few relocation types for a few architectures that do
+ * not require symbol information. For those, this value will be
+ * NULL. Implementations of these functions must be able to handle
+ * that case.
* addr - The address that requires the relocation.
*
* Returned Value:
@@ -113,6 +117,15 @@ int up_relocate(FAR const Elf32_Rel *rel, FAR const Elf32_Sym *sym,
{
FAR uint32_t *ptr = (FAR uint32_t *)addr;
+ /* All relocations depend upon having valid symbol information. */
+
+ if (sym == NULL)
+ {
+ return -EINVAL;
+ }
+
+ /* Handle the relocation by relocation type */
+
switch (ELF32_R_TYPE(rel->r_info))
{
case R_386_32:
@@ -124,7 +137,7 @@ int up_relocate(FAR const Elf32_Rel *rel, FAR const Elf32_Sym *sym,
break;
default:
- return -EINVAL;
+ return -EINVAL;
}
return OK;