Back to index

enigmail  1.4.3
Public Member Functions | Protected Attributes | Private Attributes
ElfRelHack_Section Class Reference
Inheritance diagram for ElfRelHack_Section:
Inheritance graph
[legend]
Collaboration diagram for ElfRelHack_Section:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ElfRelHack_Section (Elf_Shdr &s)
void serialize (std::ofstream &file, char ei_class, char ei_data)
bool isRelocatable ()
void push_back (Elf_RelHack &r)
const char * getName ()
unsigned int getType ()
unsigned int getFlags ()
unsigned int getAddr ()
unsigned int getSize ()
unsigned int getAddrAlign ()
unsigned int getEntSize ()
const char * getData ()
ElfSectiongetLink ()
SectionInfo getInfo ()
void shrink (unsigned int newsize)
unsigned int getOffset ()
int getIndex ()
Elf_ShdrgetShdr ()
ElfSectiongetNext ()
ElfSectiongetPrevious ()
void insertAfter (ElfSection *section, bool dirty=true)
void markDirty ()

Protected Attributes

Elf_Shdr shdr
char * data
const char * name

Private Attributes

std::vector< Elf_RelHackrels

Detailed Description

Definition at line 88 of file elfhack.cpp.


Constructor & Destructor Documentation

Definition at line 90 of file elfhack.cpp.

    : ElfSection(s, NULL, NULL)
    {
        name = elfhack_data;
    };

Member Function Documentation

unsigned int ElfSection::getAddr ( ) [inherited]

Definition at line 483 of file elf.cpp.

{
    if (shdr.sh_addr != (Elf32_Word)-1)
        return shdr.sh_addr;

    // It should be safe to adjust sh_addr for all allocated sections that
    // are neither SHT_NOBITS nor SHT_PROGBITS
    if ((previous != NULL) && isRelocatable()) {
        unsigned int addr = previous->getAddr();
        if (previous->getType() != SHT_NOBITS)
            addr += previous->getSize();

        if (addr & (getAddrAlign() - 1))
            addr = (addr | (getAddrAlign() - 1)) + 1;

        return (shdr.sh_addr = addr);
    }
    return shdr.sh_addr;
}

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned int ElfSection::getAddrAlign ( ) [inline, inherited]

Definition at line 342 of file elfxx.h.

{ return shdr.sh_addralign; }

Here is the caller graph for this function:

const char* ElfSection::getData ( ) [inline, inherited]

Definition at line 344 of file elfxx.h.

{ return data; }

Here is the caller graph for this function:

unsigned int ElfSection::getEntSize ( ) [inline, inherited]

Definition at line 343 of file elfxx.h.

{ return shdr.sh_entsize; }

Here is the caller graph for this function:

unsigned int ElfSection::getFlags ( ) [inline, inherited]

Definition at line 339 of file elfxx.h.

{ return shdr.sh_flags; }

Here is the caller graph for this function:

int ElfSection::getIndex ( ) [inherited]

Definition at line 541 of file elf.cpp.

{
    if (index != -1)
        return index;
    if (getType() == SHT_NULL)
        return (index = 0);
    ElfSection *reference;
    for (reference = previous; (reference != NULL) && (reference->getType() == SHT_NULL); reference = reference->getPrevious());
    if (reference == NULL)
        return (index = 1);
    return (index = reference->getIndex() + 1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

SectionInfo ElfSection::getInfo ( ) [inline, inherited]

Definition at line 346 of file elfxx.h.

{ return info; }

Here is the caller graph for this function:

ElfSection* ElfSection::getLink ( ) [inline, inherited]

Definition at line 345 of file elfxx.h.

{ return link; }

Here is the caller graph for this function:

const char* ElfSection::getName ( ) [inline, inherited]

Definition at line 337 of file elfxx.h.

{ return name; }

Here is the caller graph for this function:

ElfSection* ElfSection::getNext ( ) [inline, inherited]

Definition at line 360 of file elfxx.h.

{ return next; }

Here is the caller graph for this function:

unsigned int ElfSection::getOffset ( ) [inherited]

Definition at line 503 of file elf.cpp.

{
    if (shdr.sh_offset != (Elf32_Word)-1)
        return shdr.sh_offset;

    if (previous == NULL)
        return (shdr.sh_offset = 0);

    unsigned int offset = previous->getOffset();
    if (previous->getType() != SHT_NOBITS)
        offset += previous->getSize();

    Elf32_Word align = 0x1000;
    for (std::vector<ElfSegment *>::iterator seg = segments.begin(); seg != segments.end(); seg++)
        align = std::max(align, (*seg)->getAlign());

    Elf32_Word mask = align - 1;
    // SHF_TLS is used for .tbss which is some kind of special case.
    if (((getType() != SHT_NOBITS) || (getFlags() & SHF_TLS)) && (getFlags() & SHF_ALLOC)) {
        if ((getAddr() & mask) < (offset & mask))
            offset = (offset | mask) + (getAddr() & mask) + 1;
        else
            offset = (offset & ~mask) + (getAddr() & mask);
    }
    if ((getType() != SHT_NOBITS) && (offset & (getAddrAlign() - 1)))
        offset = (offset | (getAddrAlign() - 1)) + 1;

    // Two subsequent sections can't be mapped in the same page in memory
    // if they aren't in the same 4K block on disk.
    if ((getType() != SHT_NOBITS) && getAddr()) {
        if (((offset >> 12) != (previous->getOffset() >> 12)) &&
            ((getAddr() >> 12) == (previous->getAddr() >> 12)))
            throw std::runtime_error("Moving section would require overlapping segments");
    }

    return (shdr.sh_offset = offset);
}

Here is the call graph for this function:

Here is the caller graph for this function:

ElfSection* ElfSection::getPrevious ( ) [inline, inherited]

Definition at line 361 of file elfxx.h.

{ return previous; }

Here is the caller graph for this function:

Elf_Shdr & ElfSection::getShdr ( ) [inherited]

Definition at line 554 of file elf.cpp.

{
    getOffset();
    if (shdr.sh_link == (Elf32_Word)-1)
        shdr.sh_link = getLink() ? getLink()->getIndex() : 0;
    if (shdr.sh_info == (Elf32_Word)-1)
        shdr.sh_info = ((getType() == SHT_REL) || (getType() == SHT_RELA)) ?
                       (getInfo().section ? getInfo().section->getIndex() : 0) :
                       getInfo().index;

    return shdr;
}

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned int ElfSection::getSize ( ) [inline, inherited]

Definition at line 341 of file elfxx.h.

{ return shdr.sh_size; }

Here is the caller graph for this function:

unsigned int ElfSection::getType ( ) [inline, inherited]

Definition at line 338 of file elfxx.h.

{ return shdr.sh_type; }

Here is the caller graph for this function:

void ElfSection::insertAfter ( ElfSection section,
bool  dirty = true 
) [inline, inherited]

Definition at line 379 of file elfxx.h.

                                                             {
        if (previous != NULL)
            previous->next = next;
        if (next != NULL)
            next->previous = previous;
        previous = section;
        if (section != NULL) {
            next = section->next;
            section->next = this;
        } else
            next = NULL;
        if (next != NULL)
            next->previous = this;
        if (dirty)
            markDirty();
    }

Here is the call graph for this function:

Here is the caller graph for this function:

bool ElfRelHack_Section::isRelocatable ( ) [inline, virtual]

Reimplemented from ElfSection.

Definition at line 103 of file elfhack.cpp.

                         {
        return true;
    }
void ElfSection::markDirty ( ) [inline, inherited]

Definition at line 396 of file elfxx.h.

                     {
        if (link != NULL)
            shdr.sh_link = -1;
        if (info.index)
            shdr.sh_info = -1;
        shdr.sh_offset = -1;
        if (isRelocatable())
            shdr.sh_addr = -1;
        if (next)
            next->markDirty();
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 107 of file elfhack.cpp.

                                   {
        rels.push_back(r);
        shdr.sh_size = rels.size() * shdr.sh_entsize;
    }

Here is the caller graph for this function:

void ElfRelHack_Section::serialize ( std::ofstream &  file,
char  ei_class,
char  ei_data 
) [inline, virtual]

Reimplemented from ElfSection.

Definition at line 96 of file elfhack.cpp.

    {
        for (std::vector<Elf_RelHack>::iterator i = rels.begin();
             i != rels.end(); ++i)
            (*i).serialize(file, ei_class, ei_data);
    }
void ElfSection::shrink ( unsigned int  newsize) [inline, inherited]

Definition at line 348 of file elfxx.h.

                                      {
        if (newsize < shdr.sh_size) {
            shdr.sh_size = newsize;
            if (next)
                next->markDirty();
        }
    }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

char* ElfSection::data [protected, inherited]

Definition at line 431 of file elfxx.h.

const char* ElfSection::name [protected, inherited]

Definition at line 432 of file elfxx.h.

std::vector<Elf_RelHack> ElfRelHack_Section::rels [private]

Definition at line 112 of file elfhack.cpp.

Elf_Shdr ElfSection::shdr [protected, inherited]

Definition at line 430 of file elfxx.h.


The documentation for this class was generated from the following file: