summaryrefslogtreecommitdiff
path: root/src/format
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2017-03-29 21:01:51 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2017-03-29 21:01:51 (GMT)
commitb8d5a539b1e6837f7395598a3fa25ef69650e885 (patch)
tree2fbf770b1aebf1b66a8ac87e2eeae4521775d092 /src/format
parent4f3f96c2c98ac507f4aa7c83e2393c5c1fdd3cdd (diff)
Handled areas which are not allocated in memory.
Diffstat (limited to 'src/format')
-rw-r--r--src/format/elf/elf.c3
-rw-r--r--src/format/executable-int.c20
-rw-r--r--src/format/executable.c7
3 files changed, 13 insertions, 17 deletions
diff --git a/src/format/elf/elf.c b/src/format/elf/elf.c
index e874c86..0ad90ff 100644
--- a/src/format/elf/elf.c
+++ b/src/format/elf/elf.c
@@ -490,9 +490,6 @@ static void g_elf_format_refine_portions(GElfFormat *format)
sh_flags = ELF_SHDR(format, shdr, sh_flags);
- if ((sh_flags & SHF_ALLOC) == 0)
- continue;
-
if (sh_flags & SHF_EXECINSTR) background = BPC_CODE;
else if (sh_flags & SHF_WRITE) background = BPC_DATA;
else background = BPC_DATA_RO;
diff --git a/src/format/executable-int.c b/src/format/executable-int.c
index eff3d39..ebea16e 100644
--- a/src/format/executable-int.c
+++ b/src/format/executable-int.c
@@ -41,13 +41,7 @@
bool g_exe_format_without_virt_translate_offset_into_vmpa(const GExeFormat *format, phys_t off, vmpa2t *pos)
{
- /**
- * On ne peut pas initialiser la partie virtuelle à VMPA_NO_VIRTUAL
- * car les manipulations au niveau des formats (par exemple, cf. la fonction
- * g_binary_format_add_symbol()) attendent des définitions complètes.
- */
-
- init_vmpa(pos, off, off);
+ init_vmpa(pos, off, VMPA_NO_VIRTUAL);
return true;
@@ -71,12 +65,16 @@ bool g_exe_format_without_virt_translate_offset_into_vmpa(const GExeFormat *form
bool g_exe_format_without_virt_translate_address_into_vmpa(const GExeFormat *format, virt_t addr, vmpa2t *pos)
{
/**
- * Comme les sauts dans le code sont considérés en mémoire virtuelle,
- * on tolère la considération de champs virtuels même si l'architecture n'en
- * a pas la définition.
+ * S'il n'y a pas de notion de mémoire virtuelle, positions physiques et
+ * adresses virtuelles se confondent.
+ *
+ * On reste néanmoins cohérent, et on n'utilise donc pas d'adresse virtuelle.
+ *
+ * Les sauts dans le code renvoient de façon transparente vers des positions
+ * physiques.
*/
- init_vmpa(pos, addr, addr);
+ init_vmpa(pos, addr, VMPA_NO_VIRTUAL);
return true;
diff --git a/src/format/executable.c b/src/format/executable.c
index 0153f69..3d3847c 100644
--- a/src/format/executable.c
+++ b/src/format/executable.c
@@ -24,7 +24,6 @@
#include "executable.h"
-#include <assert.h>
#include <malloc.h>
#include <stdlib.h>
@@ -267,8 +266,10 @@ bool g_executable_format_complete_loading(GExeFormat *format, GtkStatusStack *st
if (result)
{
- result = g_exe_format_translate_offset_into_vmpa(format, 0, &addr);
- assert(result);
+ /**
+ * Avant de lire l'entête du format, on ne sait pas où on se trouve !
+ */
+ init_vmpa(&addr, 0, VMPA_NO_VIRTUAL);
length = g_binary_content_compute_size(base->content);