libtransistor
A userland library for the Nintendo Switch
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
Data Structures | Macros | Enumerations | Functions
elf.h File Reference

ELF structures. More...

#include <libtransistor/types.h>
#include <assert.h>
#include <stdint.h>
Include dependency graph for elf.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  Elf64_Dyn
 
struct  Elf64_Rela
 
struct  Elf64_Rel
 
struct  Elf64_Sym
 
struct  Elf64_Ehdr
 
struct  Elf64_Phdr
 

Macros

#define STN_UNDEF   0
 
#define SHN_UNDEF   0
 

Enumerations

enum  {
  EI_MAG0, EI_MAG1, EI_MAG2, EI_MAG3,
  EI_CLASS, EI_DATA, EI_VERSION, EI_OSABI,
  EI_ABIVERSION, EI_NIDENT = 16
}
 
enum  { PF_X = 0x1, PF_W = 0x2, PF_R = 0x4 }
 
enum  { PT_NULL, PT_LOAD, PT_DYNAMIC }
 
enum  {
  DT_NULL = 0, DT_NEEDED = 1, DT_PLTRELSZ = 2, DT_PLTGOT = 3,
  DT_HASH = 4, DT_STRTAB = 5, DT_SYMTAB = 6, DT_RELA = 7,
  DT_RELASZ = 8, DT_RELAENT = 9, DT_STRSZ = 10, DT_SYMENT = 11,
  DT_SYMBOLIC = 16, DT_REL = 17, DT_RELSZ = 18, DT_RELENT = 19,
  DT_PLTREL = 20, DT_JMPREL = 23, DT_INIT_ARRAY = 25, DT_FINI_ARRAY = 26,
  DT_INIT_ARRAYSZ = 27, DT_FINI_ARRAYSZ = 28, DT_FLAGS = 30, DT_GNU_HASH = 0x6ffffef5,
  DT_RELACOUNT = 0x6ffffff9
}
 

Functions

result_t elf_dynamic_find_value (Elf64_Dyn *dynamic, int64_t tag, uint64_t *value)
 Finds the value of the given tag in a dynamic section. More...
 
result_t elf_dynamic_find_offset (Elf64_Dyn *dynamic, int64_t tag, void **value, void *base)
 Finds the value of the given tag in the dynamic section, treated as an offset from a given base. More...
 
uint64_t elf_hash_string (const char *string)
 Hashes a string for lookup in the .hash table.
 

Detailed Description

ELF structures.

Function Documentation

result_t elf_dynamic_find_offset ( Elf64_Dyn dynamic,
int64_t  tag,
void **  value,
void *  base 
)

Finds the value of the given tag in the dynamic section, treated as an offset from a given base.

Returns
RESULT_OK, LIBTRANSISTOR_ERR_TRNLD_DUPLICATE_DT_ENTRY, or LIBTRANSISTOR_ERR_TRNLD_MISSING_DT_ENTRY
result_t elf_dynamic_find_value ( Elf64_Dyn dynamic,
int64_t  tag,
uint64_t *  value 
)

Finds the value of the given tag in a dynamic section.

Returns
RESULT_OK, LIBTRANSISTOR_ERR_TRNLD_DUPLICATE_DT_ENTRY, or LIBTRANSISTOR_ERR_TRNLD_MISSING_DT_ENTRY