Main Page   Modules   Data Structures   File List   Data Fields   Examples  

Relocateables
[Section Headers]


Functions

ELF_SPEC_HEADERmelf_relocTableCreate (MELF *melf, const char *name, unsigned char hasAddends)
void melf_relocInitializeRelEntryList (MELF *melf, ELF_SPEC_HEADER *sect)
void melf_relocSynchronizeRelEntryList (MELF *melf, ELF_SPEC_HEADER *sect)
void melf_relocInitializeRelaEntryList (MELF *melf, ELF_SPEC_HEADER *sect)
void melf_relocSynchronizeRelaEntryList (MELF *melf, ELF_SPEC_HEADER *sect)
void melf_relocTableSetSymbolTableHeader (MELF *melf, ELF_SPEC_HEADER *relocTable, ELF_SPEC_HEADER *symTable)
Elf32_Rel * melf_relocTableAddRel (MELF *melf, ELF_SPEC_HEADER *relocTable)
Elf32_Rel * melf_relocTableEnumRel (MELF *melf, ELF_SPEC_HEADER *relocTable, unsigned long index)
unsigned long melf_relocTableRemoveRel (MELF *melf, ELF_SPEC_HEADER *relocTable, Elf32_Rel *rel)
Elf32_Rela * melf_relocTableAddRela (MELF *melf, ELF_SPEC_HEADER *relocTable)
Elf32_Rela * melf_relocTableEnumRela (MELF *melf, ELF_SPEC_HEADER *relocTable, unsigned long index)
unsigned long melf_relocTableRemoveRela (MELF *melf, ELF_SPEC_HEADER *relocTable, Elf32_Rela *rela)
unsigned long melf_relocRecalculateOffsets (MELF *melf, ELF_SPEC_HEADER *relatedSection, unsigned long offset, unsigned long contentLength)
void melf_relocRelInitialize (MELF *melf, ELF_SPEC_HEADER *relocTable, Elf32_Rel *rel, Elf32_Addr offset, unsigned char symbolIndex, unsigned char type)
void melf_relocRelSetOffset (MELF *melf, ELF_SPEC_HEADER *relocTable, Elf32_Rel *rel, Elf32_Addr offset)
Elf32_Addr melf_relocRelGetOffset (MELF *melf, ELF_SPEC_HEADER *relocTable, Elf32_Rel *rel)
void melf_relocRelSetSymbol (MELF *melf, ELF_SPEC_HEADER *relocTable, Elf32_Rel *rel, unsigned char symbolIndex)
unsigned char melf_relocRelGetSymbol (MELF *melf, ELF_SPEC_HEADER *relocTable, Elf32_Rel *rel)
void melf_relocRelSetType (MELF *melf, ELF_SPEC_HEADER *relocTable, Elf32_Rel *rel, unsigned char type)
unsigned char melf_relocRelGetType (MELF *melf, ELF_SPEC_HEADER *relocTable, Elf32_Rel *rel)
void melf_relocRelaInitialize (MELF *melf, ELF_SPEC_HEADER *relocTable, Elf32_Rela *rela, Elf32_Addr offset, unsigned char symbolIndex, unsigned char type, Elf32_Sword addend)
void melf_relocRelaSetOffset (MELF *melf, ELF_SPEC_HEADER *relocTable, Elf32_Rela *rela, Elf32_Addr offset)
Elf32_Addr melf_relocRelaGetOffset (MELF *melf, ELF_SPEC_HEADER *relocTable, Elf32_Rela *rela)
void melf_relocRelaSetSymbol (MELF *melf, ELF_SPEC_HEADER *relocTable, Elf32_Rela *rela, unsigned char symbolIndex)
unsigned char melf_relocRelaGetSymbol (MELF *melf, ELF_SPEC_HEADER *relocTable, Elf32_Rela *rela)
void melf_relocRelaSetType (MELF *melf, ELF_SPEC_HEADER *relocTable, Elf32_Rela *rela, unsigned char type)
unsigned char melf_relocRelaGetType (MELF *melf, ELF_SPEC_HEADER *relocTable, Elf32_Rela *rela)
void melf_relocRelaSetAddend (MELF *melf, ELF_SPEC_HEADER *relocTable, Elf32_Rela *rela, Elf32_Sword addend)
Elf32_Sword melf_relocRelaGetAddend (MELF *melf, ELF_SPEC_HEADER *relocTable, Elf32_Rela *rela)

Function Documentation

void melf_relocInitializeRelaEntryList MELF   melf,
ELF_SPEC_HEADER   sect
 

Initializes the rela entry list for the given section. It is not recommended that this function be called directly.

Parameters:
melf  [in] The melf context.
sect  [in] The section that is being operated on.

void melf_relocInitializeRelEntryList MELF   melf,
ELF_SPEC_HEADER   sect
 

Initializes the rel entry list for the given section. It is not recommended that this function be called directly.

Parameters:
melf  [in] The melf context.
sect  [in] The section that is being operated on.

unsigned long melf_relocRecalculateOffsets MELF   melf,
ELF_SPEC_HEADER   relatedSection,
unsigned long    offset,
unsigned long    contentLength
 

Adjusts offsets of relocateables in a related section.

Parameters:
melf  [in] The melf context.
relatedSection  [in] The section that has been modified and is potentially related to some reloc tables.
offset  [in] The offset at which new content was inserted.
contentLength  [in] The length of the content that was inserted.
Returns:
On success, the number of relocs adjusted is returned. Otherwise, 0 is returned if none were adjusted.

Elf32_Sword melf_relocRelaGetAddend MELF   melf,
ELF_SPEC_HEADER   relocTable,
Elf32_Rela *    rela
 

Gets the addend of the reloc (addend) entry.

Parameters:
melf  [in] The melf context.
relocTable  [in] The reloc section being operated on.
rela  [in] The reloc (addend) entry.
Returns:
The reloc entry addend.

Elf32_Addr melf_relocRelaGetOffset MELF   melf,
ELF_SPEC_HEADER   relocTable,
Elf32_Rela *    rela
 

Gets the offset associated with the reloc (addend) entry.

Parameters:
melf  [in] The melf context.
relocTable  [in] The reloc section being operated on.
rela  [in] The reloc (addend) entry.
Returns:
The offset of the reloc (addend) entry.

unsigned char melf_relocRelaGetSymbol MELF   melf,
ELF_SPEC_HEADER   relocTable,
Elf32_Rela *    rela
 

Gets the symbol index associated with the reloc (addend) entry.

Parameters:
melf  [in] The melf context.
relocTable  [in] The reloc section being operated on.
rela  [in] The reloc (addend) entry.
Returns:
The index of the associated symbol.

unsigned char melf_relocRelaGetType MELF   melf,
ELF_SPEC_HEADER   relocTable,
Elf32_Rela *    rela
 

Gets the type of the reloc (addend) entry.

Parameters:
melf  [in] The melf context.
relocTable  [in] The reloc section being operated on.
rela  [in] The reloc (addend) entry.
Returns:
The type of the entry.

void melf_relocRelaInitialize MELF   melf,
ELF_SPEC_HEADER   relocTable,
Elf32_Rela *    rela,
Elf32_Addr    offset,
unsigned char    symbolIndex,
unsigned char    type,
Elf32_Sword    addend
 

Initializes a reloc (addend) entry to a given set of values.

Parameters:
melf  [in] The melf context.
relocTable  [in] The reloc section being operated on.
rela  [in] The reloc (addend) entry to be initialized.
offset  [in] The offset to which the reloc points.
symbolIndex  [in] The index of the symbol to which the reloc entry refers, if any.
type  [in] The type of reloc.
addend  [in] The addend associated with the reloc entry.
Examples:
new.c.

void melf_relocRelaSetAddend MELF   melf,
ELF_SPEC_HEADER   relocTable,
Elf32_Rela *    rela,
Elf32_Sword    addend
 

Sets the addend of the reloc (addend) entry.

Parameters:
melf  [in] The melf context.
relocTable  [in] The reloc section being operated on.
rela  [in] The reloc (addend) entry.
addend  [in] The reloc entry addend.

void melf_relocRelaSetOffset MELF   melf,
ELF_SPEC_HEADER   relocTable,
Elf32_Rela *    rela,
Elf32_Addr    offset
 

Sets the offset associated with the reloc (addend) entry.

Parameters:
melf  [in] The melf context.
relocTable  [in] The reloc section being operated on.
rela  [in] The reloc (addend) entry.
offset  [in] The offset.

void melf_relocRelaSetSymbol MELF   melf,
ELF_SPEC_HEADER   relocTable,
Elf32_Rela *    rela,
unsigned char    symbolIndex
 

Sets the symbol index associated with the reloc (addend) entry.

Parameters:
melf  [in] The melf context.
relocTable  [in] The reloc section being operated on.
rela  [in] The reloc (addend) entry.
symbolIndex  [in] The index of the symbol being associated.

void melf_relocRelaSetType MELF   melf,
ELF_SPEC_HEADER   relocTable,
Elf32_Rela *    rela,
unsigned char    type
 

Sets the type of the reloc (addend) entry.

type can be one of the following for 386:

  • R_386_NONE No reloc
  • R_386_32 Direct 32 bit
  • R_386_PC32 PC relative 32 bit
  • R_386_GOT32 32 bit GOT entry
  • R_386_PLT32 32 bit PLT address
  • R_386_COPY Copy of symbol at runtime
  • R_386_GLOB_DAT Create GOT entry
  • R_386_JMP_SLOT Create PLT entry
  • R_386_RELATIVE Adjust by program base
  • R_386_GOTOFF 32 bit offset to GOT
  • R_386_GOTPC 32 bit PC relative offset to GOT
Parameters:
melf  [in] The melf context.
relocTable  [in] The reloc section being operated on.
rela  [in] The reloc (addend) entry.
type  [in] The type of the entry.

Elf32_Addr melf_relocRelGetOffset MELF   melf,
ELF_SPEC_HEADER   relocTable,
Elf32_Rel *    rel
 

Gets the offset of a given reloc entry.

Parameters:
melf  [in] The melf context.
relocTable  [in] The reloc section being operated on.
rel  [in] The reloc entry being operated on.
Returns:
The offset of the reloc entry.

unsigned char melf_relocRelGetSymbol MELF   melf,
ELF_SPEC_HEADER   relocTable,
Elf32_Rel *    rel
 

Gets the symbol index associated with the reloc entry.

Parameters:
melf  [in] The melf context.
relocTable  [in] The reloc section being operated on.
rel  [in] The reloc entry being operated on.
Returns:
The symbol index associated with the reloc entry.

unsigned char melf_relocRelGetType MELF   melf,
ELF_SPEC_HEADER   relocTable,
Elf32_Rel *    rel
 

Gets the type of the reloc entry.

Parameters:
melf  [in] The melf context.
relocTable  [in] The reloc section being operated on.
rel  [in] The reloc entry being operated on.
Returns:
The type of the reloc entry.

void melf_relocRelInitialize MELF   melf,
ELF_SPEC_HEADER   relocTable,
Elf32_Rel *    rel,
Elf32_Addr    offset,
unsigned char    symbolIndex,
unsigned char    type
 

Initializes a reloc entry to a given set of values.

Parameters:
melf  [in] The melf context.
relocTable  [in] The reloc section being operated on.
rel  [in] The reloc entry to be initialized.
offset  [in] The offset to which the reloc points.
symbolIndex  [in] The index of the symbol to which the reloc entry refers, if any.
type  [in] The type of reloc.
Examples:
new.c.

void melf_relocRelSetOffset MELF   melf,
ELF_SPEC_HEADER   relocTable,
Elf32_Rel *    rel,
Elf32_Addr    offset
 

Sets the offset of a given reloc entry.

Parameters:
melf  [in] The melf context.
relocTable  [in] The reloc section being operated on.
rel  [in] The reloc entry being operated on.
offset  [in] The offset to which the reloc points.

void melf_relocRelSetSymbol MELF   melf,
ELF_SPEC_HEADER   relocTable,
Elf32_Rel *    rel,
unsigned char    symbolIndex
 

Sets the symbol index associated with the reloc entry.

Parameters:
melf  [in] The melf context.
relocTable  [in] The reloc section being operated on.
rel  [in] The reloc entry being operated on.
symbolIndex  [in] The index of the symbol to which the reloc refers.

void melf_relocRelSetType MELF   melf,
ELF_SPEC_HEADER   relocTable,
Elf32_Rel *    rel,
unsigned char    type
 

Sets the type of the reloc entry.

type can be one of the following for 386:

  • R_386_NONE No reloc
  • R_386_32 Direct 32 bit
  • R_386_PC32 PC relative 32 bit
  • R_386_GOT32 32 bit GOT entry
  • R_386_PLT32 32 bit PLT address
  • R_386_COPY Copy of symbol at runtime
  • R_386_GLOB_DAT Create GOT entry
  • R_386_JMP_SLOT Create PLT entry
  • R_386_RELATIVE Adjust by program base
  • R_386_GOTOFF 32 bit offset to GOT
  • R_386_GOTPC 32 bit PC relative offset to GOT
Parameters:
melf  [in] The melf context.
relocTable  [in] The reloc section being operated on.
rel  [in] The reloc entry being operated on.
type  [in] The reloc entry's type.

void melf_relocSynchronizeRelaEntryList MELF   melf,
ELF_SPEC_HEADER   sect
 

Synchronizess the rel entry list for the given section. It is not recommended that this function be called directly.

Parameters:
melf  [in] The melf context.
sect  [in] The section that is being operated on.

void melf_relocSynchronizeRelEntryList MELF   melf,
ELF_SPEC_HEADER   sect
 

Synchronizess the rel entry list for the given section. It is not recommended that this function be called directly.

Parameters:
melf  [in] The melf context.
sect  [in] The section that is being operated on.

Elf32_Rel* melf_relocTableAddRel MELF   melf,
ELF_SPEC_HEADER   relocTable
 

Adds an uninitialized relocateable entry to the table.

Parameters:
melf  [in] The melf context.
relocTable  [in] The reloc section being operated on.
Returns:
On success, a valid pointer to a reloc entry is returned. Otherwise, NULL is returned.
Examples:
new.c.

Elf32_Rela* melf_relocTableAddRela MELF   melf,
ELF_SPEC_HEADER   relocTable
 

Adds an uninitialized reloc entry (with addend) to the table.

Parameters:
melf  [in] The melf context.
relocTable  [in] The reloc section being operated on.
Returns:
On success, a valid pointer to the reloc (addend) entry is returned. Otherwise, NULL is returned.
Examples:
new.c.

ELF_SPEC_HEADER* melf_relocTableCreate MELF   melf,
const char *    name,
unsigned char    hasAddends
 

Creates a relocateable section in the binary with a given name. If addends is set to 1 the section will contain Elf32_Rela's, if it is set to zero, it will contain Elf32_Rel's.

Parameters:
melf  [in] The melf context.
name  [in] The name of the section.
hasAddends  [in] 1 if the section will have addends, 0 if not.
Returns:
On success, an valid ELF section pointer is returned. Otherwise, NULL is returned.
Examples:
new.c.

Elf32_Rel* melf_relocTableEnumRel MELF   melf,
ELF_SPEC_HEADER   relocTable,
unsigned long    index
 

Enumerates the reloc table at the given index.

Parameters:
melf  [in] The melf context.
relocTable  [in] The reloc section being operated on.
index  [in] The index at which to enumerate.
Returns:
On success, a valid pointer to a reloc entry is returned. Otherwise, NULL is returned.
Examples:
new.c.

Elf32_Rela* melf_relocTableEnumRela MELF   melf,
ELF_SPEC_HEADER   relocTable,
unsigned long    index
 

Enumerates the reloc table at the given index.

Parameters:
melf  [in] The melf context.
relocTable  [in] The reloc section being operated on.
index  [in] The index at which to enumerate.
Returns:
On success, a valid pointer to a reloc (addend) entry is returned. Otherwise, NULL is returned.
Examples:
new.c.

unsigned long melf_relocTableRemoveRel MELF   melf,
ELF_SPEC_HEADER   relocTable,
Elf32_Rel *    rel
 

Removes a reloc entry from the table. All entries that match the reloc entry passed in will be removed from the table.

Parameters:
melf  [in] The melf context.
relocTable  [in] The reloc section being operated on.
rel  [in] The reloc entry to remove.
Returns:
On success a non-zero value is returned to indicate the number of entries removed. Otherwise, zero is returned.
Examples:
new.c.

unsigned long melf_relocTableRemoveRela MELF   melf,
ELF_SPEC_HEADER   relocTable,
Elf32_Rela *    rela
 

Removes a reloc (addend) entry from the table. All entries taht match the reloc entry passed in will be removed from the table.

Parameters:
melf  [in] The melf context.
relocTable  [in] The reloc section being operated on.
rela  [in] The reloc (addend) entry to be removed.
Returns:
On success a non-zero value is returned to indicate the number of entries removed. Otherwise, zero is returned.
Examples:
new.c.

void melf_relocTableSetSymbolTableHeader MELF   melf,
ELF_SPEC_HEADER   relocTable,
ELF_SPEC_HEADER   symTable
 

Set the symbol table header associated with the relocateables in this section.

Parameters:
melf  [in] The melf context.
relocTable  [in] The reloc section being operated on.
symTable  [in] The symbol table to be associated.
Examples:
new.c.


Generated on Tue May 4 00:14:34 2004 for libmelf by doxygen1.2.15