summaryrefslogtreecommitdiff
path: root/src/format/elf/section.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/format/elf/section.c')
-rw-r--r--src/format/elf/section.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/src/format/elf/section.c b/src/format/elf/section.c
index 3feb869..2b46d9e 100644
--- a/src/format/elf/section.c
+++ b/src/format/elf/section.c
@@ -48,7 +48,7 @@
bool find_elf_section_by_index(const GElfFormat *format, uint16_t index, elf_shdr *section)
{
- off_t offset; /* Emplacement à venir lire */
+ phys_t offset; /* Emplacement à venir lire */
if (index >= ELF_HDR(format, format->header, e_shnum)) return false;
@@ -118,7 +118,7 @@ bool find_elf_section_by_name(const GElfFormat *format, const char *name, elf_sh
* *
******************************************************************************/
-bool find_elf_section_by_virtual_address(const GElfFormat *format, uint32_t addr, elf_shdr *section)
+bool find_elf_section_by_virtual_address(const GElfFormat *format, virt_t addr, elf_shdr *section)
{
bool result; /* Bilan à faire remonter */
uint16_t i; /* Boucle de parcours */
@@ -194,7 +194,7 @@ bool find_elf_sections_by_type(const GElfFormat *format, uint32_t type, elf_shdr
* *
******************************************************************************/
-void get_elf_section_content(const GElfFormat *format, const elf_shdr *section, off_t *offset, off_t *size, vmpa_t *addr)
+void get_elf_section_content(const GElfFormat *format, const elf_shdr *section, phys_t *offset, phys_t *size, virt_t *addr)
{
*offset = ELF_SHDR(format, *section, sh_offset);
*size = ELF_SHDR(format, *section, sh_size);
@@ -221,7 +221,7 @@ void get_elf_section_content(const GElfFormat *format, const elf_shdr *section,
* *
******************************************************************************/
-bool find_elf_section_content_by_name(const GElfFormat *format, const char *name, off_t *offset, off_t *size, vmpa_t *address)
+bool find_elf_section_content_by_name(const GElfFormat *format, const char *name, phys_t *offset, phys_t *size, virt_t *address)
{
bool result; /* Bilan à retourner */
elf_shdr section; /* Section trouvée ou non */
@@ -253,24 +253,25 @@ bool find_elf_section_content_by_name(const GElfFormat *format, const char *name
const char *extract_name_from_elf_string_section(const GElfFormat *format, const elf_shdr *section, off_t index)
{
const char *result; /* Nom trouvé à renvoyer */
- const bin_t *content; /* Contenu binaire à lire */
- off_t length; /* Taille totale du contenu */
- off_t last; /* Dernier '\0' possible */
- off_t pos; /* Point de lecture */
-
- content = G_BIN_FORMAT(format)->content;
- length = G_BIN_FORMAT(format)->length;
+ phys_t last; /* Dernier '\0' possible */
+ phys_t phys; /* Point de lecture physique */
+ vmpa2t pos; /* Position de lecture */
+ const GBinContent *content; /* Contenu binaire à lire */
last = ELF_SHDR(format, *section, sh_offset) + ELF_SHDR(format, *section, sh_size);
- pos = ELF_SHDR(format, *section, sh_offset) + index;
+ phys = ELF_SHDR(format, *section, sh_offset) + index;
- if ((pos + 1) >= MIN(length, last))
+ if ((phys + 1) >= last)
return NULL;
- result = (const char *)&content[pos];
+ init_vmpa(&pos, phys, VMPA_NO_VIRTUAL);
+
+ content = G_BIN_FORMAT(format)->content;
+
+ result = (const char *)g_binary_content_get_raw_access(content, &pos, 1);
- if ((pos + strlen(result)) > last)
+ if ((phys + strlen(result)) > last)
return NULL;
return result;