Main Page   Modules   Data Structures   File List   Data Fields   Examples  

Section Headers
[The Manipulate ELF library.]


Modules

String Table
Dynamic
Note
Symbol Table
Relocateables

Functions

ELF_SPEC_HEADERmelf_sectionAdd (MELF *melf)
ELF_SPEC_HEADERmelf_sectionGetEnum (MELF *melf)
ELF_SPEC_HEADERmelf_sectionEnumNext (MELF *melf, ELF_SPEC_HEADER *en)
ELF_SPEC_HEADERmelf_sectionEnumPrev (MELF *melf, ELF_SPEC_HEADER *en)
ELF_SPEC_HEADERmelf_sectionFindType (MELF *melf, unsigned long type)
ELF_SPEC_HEADERmelf_sectionFindIndex (MELF *melf, unsigned long index)
ELF_SPEC_HEADERmelf_sectionFindName (MELF *melf, const char *name)
void melf_sectionSetContent (MELF *melf, ELF_SPEC_HEADER *section, void *content, unsigned long contentLength)
void * melf_sectionGetContent (MELF *melf, ELF_SPEC_HEADER *section)
unsigned long melf_sectionInsertContent (MELF *melf, ELF_SPEC_HEADER *section, unsigned long offset, void *content, unsigned long contentLength)
void melf_sectionSetName (MELF *melf, ELF_SPEC_HEADER *section, const char *name)
const char * melf_sectionGetName (MELF *melf, ELF_SPEC_HEADER *section)
void melf_sectionSetType (MELF *melf, ELF_SPEC_HEADER *section, unsigned long type)
unsigned long melf_sectionGetType (MELF *melf, ELF_SPEC_HEADER *section)
void melf_sectionSetOffset (MELF *melf, ELF_SPEC_HEADER *section, Elf32_Off offset)
Elf32_Off melf_sectionGetOffset (MELF *melf, ELF_SPEC_HEADER *section)
void melf_sectionSetSize (MELF *melf, ELF_SPEC_HEADER *section, Elf32_Half size)
Elf32_Half melf_sectionGetSize (MELF *melf, ELF_SPEC_HEADER *section)
void melf_sectionSetAddress (MELF *melf, ELF_SPEC_HEADER *section, Elf32_Addr addr)
Elf32_Addr melf_sectionGetAddress (MELF *melf, ELF_SPEC_HEADER *section)
void melf_sectionSetLink (MELF *melf, ELF_SPEC_HEADER *section, Elf32_Word link)
Elf32_Word melf_sectionGetLink (MELF *melf, ELF_SPEC_HEADER *section)
void melf_sectionSetInfo (MELF *melf, ELF_SPEC_HEADER *section, Elf32_Word info)
Elf32_Word melf_sectionGetInfo (MELF *melf, ELF_SPEC_HEADER *section)
void melf_sectionSetFlags (MELF *melf, ELF_SPEC_HEADER *section, Elf32_Word flags)
Elf32_Word melf_sectionGetFlags (MELF *melf, ELF_SPEC_HEADER *section)
void melf_sectionSetEntrySize (MELF *melf, ELF_SPEC_HEADER *section, Elf32_Word entsize)
Elf32_Word melf_sectionGetEntrySize (MELF *melf, ELF_SPEC_HEADER *section)
unsigned long melf_sectionGetIndex (MELF *melf, ELF_SPEC_HEADER *section)
void melf_sectionSetStringTableHeader (MELF *melf, ELF_SPEC_HEADER *section, ELF_SPEC_HEADER *stringTable)
ELF_SPEC_HEADERmelf_sectionGetStringTableHeader (MELF *melf, ELF_SPEC_HEADER *section)
unsigned long melf_sectionRemove (MELF *melf, unsigned long id)

Function Documentation

ELF_SPEC_HEADER* melf_sectionAdd MELF   melf
 

Adds a new section.

Parameters:
melf  [in] The melf context.
Returns:
On success, a new blank section is returned.
Examples:
new.c.

ELF_SPEC_HEADER* melf_sectionEnumNext MELF   melf,
ELF_SPEC_HEADER   en
 

Gets the next entry in the section header enumeration.

Parameters:
melf  [in] The melf context.
en  [in] The current enumeration pointer.
Returns:
The next header in the enumeration.

ELF_SPEC_HEADER* melf_sectionEnumPrev MELF   melf,
ELF_SPEC_HEADER   en
 

Gets the previous entry in the section header enumeration.

Parameters:
melf  [in] The melf context.
en  [in] The current enumeration pointer.
Returns:
The previous header in the enumeration.

ELF_SPEC_HEADER* melf_sectionFindIndex MELF   melf,
unsigned long    index
 

Finds a section that is at the given index.

Parameters:
melf  [in] The melf context.
index  [in] The index to find a section at.
Returns:
If a header exists at the provided index a valid pointer will be returned, otherwise NULL is returned.

ELF_SPEC_HEADER* melf_sectionFindName MELF   melf,
const char *    name
 

Finds the first section with a given name.

Parameters:
melf  [in] The melf context.
name  [in] The name of the section to search for.
Returns:
If a header exists with the provided name a valid pointer will be returned, otherwise NULL is returned.

ELF_SPEC_HEADER* melf_sectionFindType MELF   melf,
unsigned long    type
 

Finds the first section header of a given type (e.g. SHT_NOTE)

Parameters:
melf  [in] The melf context.
type  [in] The type to search for.
Returns:
If a matching section is found a valid pointer will be returned, otherwise NULL is returned.

Elf32_Addr melf_sectionGetAddress MELF   melf,
ELF_SPEC_HEADER   section
 

Gets the virtual address associated with a section.

Parameters:
melf  [in] The melf context.
section  [in] The section to operate on.
Returns:
The virtual address associated with the section.

void* melf_sectionGetContent MELF   melf,
ELF_SPEC_HEADER   section
 

Gets the raw content for a given section.

Parameters:
melf  [in] The melf context.
section  [in] The section to retrieve the content of.
Returns:
If the specified section is valid and has content, a valid pointer is returned. Otherwise, NULL is returned.

Elf32_Word melf_sectionGetEntrySize MELF   melf,
ELF_SPEC_HEADER   section
 

Get the size of an entry in the content for the section.

Parameters:
melf  [in] The melf context.
section  [in] The section to operate on.
Returns:
The size of an entry.

ELF_SPEC_HEADER* melf_sectionGetEnum MELF   melf
 

Gets an enumerator for the section header table.

Parameters:
melf  [in] The melf context.
Returns:
On success, a pointer to the first entry in the section enumeration is returned, otherwise NULL is returned.

Elf32_Word melf_sectionGetFlags MELF   melf,
ELF_SPEC_HEADER   section
 

Get the flags of a given section.

Parameters:
melf  [in] The melf context.
section  [in] The section to get the flags of.

unsigned long melf_sectionGetIndex MELF   melf,
ELF_SPEC_HEADER   section
 

Get the index of a given section.

Parameters:
melf  [in] The melf context.
section  [in] The section to operate on.
Returns:
The index of the section.

Elf32_Word melf_sectionGetInfo MELF   melf,
ELF_SPEC_HEADER   section
 

Gets the info section associated with the section.

Parameters:
melf  [in] The melf context.
section  [in] The section to operate on.

Elf32_Word melf_sectionGetLink MELF   melf,
ELF_SPEC_HEADER   section
 

Gets the link section associated with the section.

Parameters:
melf  [in] The melf context.
section  [in] The section to operate on.

const char* melf_sectionGetName MELF   melf,
ELF_SPEC_HEADER   section
 

Gets the name of the section.

Parameters:
melf  [in] The melf context.
section  [in] The section to get the name of.
Returns:
If the section has a name a valid pointer is returned. Otherwise, NULL is returned.

Elf32_Off melf_sectionGetOffset MELF   melf,
ELF_SPEC_HEADER   section
 

Get the section's file offset.

Parameters:
melf  [in] The melf context.
section  [in] The section to operate on.
Returns:
The offset currently set on the section.

Elf32_Half melf_sectionGetSize MELF   melf,
ELF_SPEC_HEADER   section
 

Get the section's expressed content size.

Parameters:
melf  [in] The melf context.
section  [in] The section to operate on.
Returns:
The section's expressed content size.

ELF_SPEC_HEADER* melf_sectionGetStringTableHeader MELF   melf,
ELF_SPEC_HEADER   section
 

Get the string table associated with a section.

Parameters:
melf  [in] The melf context.
section  [in] The section to operate on.
Returns:
The string table section associated with the supplied section, if any.
Examples:
new.c.

unsigned long melf_sectionGetType MELF   melf,
ELF_SPEC_HEADER   section
 

Gets the section type of a given section.

Parameters:
melf  [in] The melf context.
section  [in] The section to get the type of.
Returns:
The section type.

unsigned long melf_sectionInsertContent MELF   melf,
ELF_SPEC_HEADER   section,
unsigned long    offset,
void *    content,
unsigned long    contentLength
 

Inserts new content into existing content for the given section.

Parameters:
melf  [in] The melf context.
section  [in] The section to insert content into.
offset  [in] The offset at which to insert the content.
content  [in] The content to insert.
contentLength  [in] The length of the content being inserted.
Returns:
On success, 1 is returned. Otherwise, zero is returned.

unsigned long melf_sectionRemove MELF   melf,
unsigned long    id
 

Remove a given section by its identifier.

Parameters:
melf  [in] The melf context.
id  [in] The identifier of the section to remove.
Returns:
1 if successful.

void melf_sectionSetAddress MELF   melf,
ELF_SPEC_HEADER   section,
Elf32_Addr    addr
 

Sets the virtual address associated with the section.

Parameters:
melf  [in] The melf context.
section  [in] The section to operate on.
addr  [in] The virtual address.

void melf_sectionSetContent MELF   melf,
ELF_SPEC_HEADER   section,
void *    content,
unsigned long    contentLength
 

Sets the arbitrary content for the given section.

Parameters:
melf  [in] The melf context.
section  [in] The section to operate on.
content  [in] The raw content to set. This parameter can be NULL.
contentLength  [in] The length of the raw content. 0 for no content.

void melf_sectionSetEntrySize MELF   melf,
ELF_SPEC_HEADER   section,
Elf32_Word    entsize
 

Set the size of an entry in the content for the section.

Parameters:
melf  [in] The melf context.
section  [in] The section to operate on.
entsize  [in] The size of a entry.

void melf_sectionSetFlags MELF   melf,
ELF_SPEC_HEADER   section,
Elf32_Word    flags
 

Set the flags on a given section.

Flags can be one or more of the following:

  • SHF_WRITE Writable.
  • SHF_ALLOC Occupies memory during execution.
  • SHF_EXECINSTR Contains executable code.
  • SHF_MERGE Might be merged.
  • SHF_STRINGS Contains strings.
  • SHF_INFO_LINK sh_info contains section index.
  • SHF_GROUP Section is a member of a group.
  • SHF_TLS Thread local storage.
Parameters:
melf  [in] The melf context.
section  [in] The section to set the flags on.
flags  [in] The flags to set.

void melf_sectionSetInfo MELF   melf,
ELF_SPEC_HEADER   section,
Elf32_Word    info
 

Sets the info section associated with the section.

Parameters:
melf  [in] The melf context.
section  [in] The section to operate on.
info  [in] The index of the section that is to be associated.

void melf_sectionSetLink MELF   melf,
ELF_SPEC_HEADER   section,
Elf32_Word    link
 

Sets the link section associated with the section.

Parameters:
melf  [in] The melf context.
section  [in] The section to operate on.
link  [in] The index of the section that is to be associated.

void melf_sectionSetName MELF   melf,
ELF_SPEC_HEADER   section,
const char *    name
 

Sets the name of a section. If a string table does not exist for section headers then one is created, otherwise the existing one is used.

Parameters:
melf  [in] The melf context.
section  [in] The section to operate on.
name  [in] The name to set the section to.
Examples:
new.c.

void melf_sectionSetOffset MELF   melf,
ELF_SPEC_HEADER   section,
Elf32_Off    offset
 

Set the section's file offset.

Parameters:
melf  [in] The melf context.
section  [in] The section to operate on.
offset  [in] The offset to update to.

void melf_sectionSetSize MELF   melf,
ELF_SPEC_HEADER   section,
Elf32_Half    size
 

Set the section's expressed content size. Note that this does not affect the size of the content that MELF thinks the section has, it merely updates the section header's size value.

Parameters:
melf  [in] The melf context.
section  [in] The section to operate on.
size  [in] The expressed size to update to.

void melf_sectionSetStringTableHeader MELF   melf,
ELF_SPEC_HEADER   section,
ELF_SPEC_HEADER   stringTable
 

Set the string table to associate with the section. This is used for things like symbol tables which tend to have their own string tables for symbol names.

Parameters:
melf  [in] The melf context.
section  [in] The section to operate on.
stringTable  [in] The string table section to associate with.

void melf_sectionSetType MELF   melf,
ELF_SPEC_HEADER   section,
unsigned long    type
 

Sets the specified section to a given type. (e.g. SHT_SYMTAB, SHT_STRTAB)

The type can be one of the following standard types:

  • SHT_NULL No type
  • SHT_PROGBITS Program data.
  • SHT_SYMTAB Symbol table.
  • SHT_STRTAB String table.
  • SHT_RELA Relocation entries with addends.
  • SHT_HASH Symbol hash table.
  • SHT_DYNAMIC Dynamic linking information.
  • SHT_NOTE Notes
  • SHT_NOBITS Program space with no data.
  • SHT_REL Relocation entries with no addends.
  • SHT_DYNSYM Dynamic linker symbol table.
There are more acceptable types, but these are the standard set.
Parameters:
melf  [in] The melf context.
section  [in] The section to operate on.
type  [in] The type to set the section to.
Examples:
new.c.


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