Changeset 8ff0bd2 in mainline for abi/include/elf.h


Ignore:
Timestamp:
2011-09-04T11:30:58Z (15 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/fix-logger-deadlock, topic/msim-upgrade, topic/simplify-dev-export
Children:
03bc76a
Parents:
d2c67e7 (diff), deac215e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes

File:
1 moved

Legend:

Unmodified
Added
Removed
  • abi/include/elf.h

    rd2c67e7 r8ff0bd2  
    2727 */
    2828
    29 /** @addtogroup generic 
     29/** @addtogroup generic
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #ifndef ELF_H_
    36 #define ELF_H_
    37 
    38 #include <arch/elf.h>
    39 #include <sys/types.h>
    40 
    41 /**
    42  * current ELF version
    43  */
    44 #define EV_CURRENT      1
    45 
    46 /**
    47  * ELF types
    48  */
    49 #define ET_NONE         0       /* No type */
    50 #define ET_REL          1       /* Relocatable file */
    51 #define ET_EXEC         2       /* Executable */
    52 #define ET_DYN          3       /* Shared object */
    53 #define ET_CORE         4       /* Core */
    54 #define ET_LOPROC       0xff00  /* Processor specific */
    55 #define ET_HIPROC       0xffff  /* Processor specific */
    56 
    57 /**
     35#ifndef ABI_ELF_H_
     36#define ABI_ELF_H_
     37
     38/**
     39 * Current ELF version
     40 */
     41#define EV_CURRENT  1
     42
     43/**
     44 * ELF types
     45 */
     46#define ET_NONE    0       /* No type */
     47#define ET_REL     1       /* Relocatable file */
     48#define ET_EXEC    2       /* Executable */
     49#define ET_DYN     3       /* Shared object */
     50#define ET_CORE    4       /* Core */
     51#define ET_LOPROC  0xff00  /* Processor specific */
     52#define ET_HIPROC  0xffff  /* Processor specific */
     53
     54/**
    5855 * ELF machine types
    5956 */
    60 #define EM_NO           0       /* No machine */
    61 #define EM_SPARC        2       /* SPARC */
    62 #define EM_386          3       /* i386 */
    63 #define EM_MIPS         8       /* MIPS RS3000 */
    64 #define EM_MIPS_RS3_LE  10      /* MIPS RS3000 LE */
    65 #define EM_PPC          20      /* PPC32 */
    66 #define EM_PPC64        21      /* PPC64 */
    67 #define EM_ARM          40      /* ARM */
    68 #define EM_SPARCV9      43      /* SPARC64 */
    69 #define EM_IA_64        50      /* IA-64 */
    70 #define EM_X86_64       62      /* AMD64/EMT64 */
     57#define EM_NO           0   /* No machine */
     58#define EM_SPARC        2   /* SPARC */
     59#define EM_386          3   /* i386 */
     60#define EM_MIPS         8   /* MIPS RS3000 */
     61#define EM_MIPS_RS3_LE  10  /* MIPS RS3000 LE */
     62#define EM_PPC          20  /* PPC32 */
     63#define EM_PPC64        21  /* PPC64 */
     64#define EM_ARM          40  /* ARM */
     65#define EM_SPARCV9      43  /* SPARC64 */
     66#define EM_IA_64        50  /* IA-64 */
     67#define EM_X86_64       62  /* AMD64/EMT64 */
    7168
    7269/**
    7370 * ELF identification indexes
    7471 */
    75 #define EI_MAG0         0
    76 #define EI_MAG1         1
    77 #define EI_MAG2         2
    78 #define EI_MAG3         3
    79 #define EI_CLASS        4               /* File class */
    80 #define EI_DATA         5               /* Data encoding */
    81 #define EI_VERSION      6               /* File version */
    82 #define EI_OSABI        7
    83 #define EI_ABIVERSION   8
    84 #define EI_PAD          9               /* Start of padding bytes */
    85 #define EI_NIDENT       16              /* ELF identification table size */
     72#define EI_MAG0        0
     73#define EI_MAG1        1
     74#define EI_MAG2        2
     75#define EI_MAG3        3
     76#define EI_CLASS       4   /* File class */
     77#define EI_DATA        5   /* Data encoding */
     78#define EI_VERSION     6   /* File version */
     79#define EI_OSABI       7
     80#define EI_ABIVERSION  8
     81#define EI_PAD         9   /* Start of padding bytes */
     82#define EI_NIDENT      16  /* ELF identification table size */
    8683
    8784/**
    8885 * ELF magic number
    8986 */
    90 #define ELFMAG0         0x7f
    91 #define ELFMAG1         'E'
    92 #define ELFMAG2         'L'
    93 #define ELFMAG3         'F'
     87#define ELFMAG0  0x7f
     88#define ELFMAG1  'E'
     89#define ELFMAG2  'L'
     90#define ELFMAG3  'F'
    9491
    9592/**
    9693 * ELF file classes
    9794 */
    98 #define ELFCLASSNONE    0
    99 #define ELFCLASS32      1
    100 #define ELFCLASS64      2
     95#define ELFCLASSNONE  0
     96#define ELFCLASS32    1
     97#define ELFCLASS64    2
    10198
    10299/**
    103100 * ELF data encoding types
    104101 */
    105 #define ELFDATANONE     0
    106 #define ELFDATA2LSB     1               /* Least significant byte first (little endian) */
    107 #define ELFDATA2MSB     2               /* Most signigicant byte first (big endian) */
    108 
    109 /**
    110  * ELF error return codes
    111  */
    112 #define EE_OK                   0       /* No error */
    113 #define EE_INVALID              1       /* Invalid ELF image */
    114 #define EE_MEMORY               2       /* Cannot allocate address space */
    115 #define EE_INCOMPATIBLE         3       /* ELF image is not compatible with current architecture */
    116 #define EE_UNSUPPORTED          4       /* Non-supported ELF (e.g. dynamic ELFs) */
    117 #define EE_IRRECOVERABLE        5
     102#define ELFDATANONE  0
     103#define ELFDATA2LSB  1  /* Least significant byte first (little endian) */
     104#define ELFDATA2MSB  2  /* Most signigicant byte first (big endian) */
    118105
    119106/**
    120107 * ELF section types
    121108 */
    122 #define SHT_NULL                0
    123 #define SHT_PROGBITS            1
    124 #define SHT_SYMTAB              2
    125 #define SHT_STRTAB              3
    126 #define SHT_RELA                4
    127 #define SHT_HASH                5
    128 #define SHT_DYNAMIC             6
    129 #define SHT_NOTE                7
    130 #define SHT_NOBITS              8
    131 #define SHT_REL                 9
    132 #define SHT_SHLIB               10
    133 #define SHT_DYNSYM              11
    134 #define SHT_LOOS                0x60000000
    135 #define SHT_HIOS                0x6fffffff
    136 #define SHT_LOPROC              0x70000000
    137 #define SHT_HIPROC              0x7fffffff
    138 #define SHT_LOUSER              0x80000000
    139 #define SHT_HIUSER              0xffffffff
     109#define SHT_NULL      0
     110#define SHT_PROGBITS  1
     111#define SHT_SYMTAB    2
     112#define SHT_STRTAB    3
     113#define SHT_RELA      4
     114#define SHT_HASH      5
     115#define SHT_DYNAMIC   6
     116#define SHT_NOTE      7
     117#define SHT_NOBITS    8
     118#define SHT_REL       9
     119#define SHT_SHLIB     10
     120#define SHT_DYNSYM    11
     121#define SHT_LOOS      0x60000000
     122#define SHT_HIOS      0x6fffffff
     123#define SHT_LOPROC    0x70000000
     124#define SHT_HIPROC    0x7fffffff
     125#define SHT_LOUSER    0x80000000
     126#define SHT_HIUSER    0xffffffff
    140127
    141128/**
    142129 * ELF section flags
    143130 */
    144 #define SHF_WRITE               0x1
    145 #define SHF_ALLOC               0x2
    146 #define SHF_EXECINSTR           0x4
    147 #define SHF_TLS                 0x400
    148 #define SHF_MASKPROC            0xf0000000
     131#define SHF_WRITE      0x1
     132#define SHF_ALLOC      0x2
     133#define SHF_EXECINSTR  0x4
     134#define SHF_TLS        0x400
     135#define SHF_MASKPROC   0xf0000000
    149136
    150137/** Macros for decomposing elf_symbol.st_info into binging and type */
    151 #define ELF_ST_BIND(i)          ((i) >> 4)
    152 #define ELF_ST_TYPE(i)          ((i) & 0x0f)
    153 #define ELF_ST_INFO(b, t)       (((b) << 4) + ((t) & 0x0f))
     138#define ELF_ST_BIND(i)     ((i) >> 4)
     139#define ELF_ST_TYPE(i)     ((i) & 0x0f)
     140#define ELF_ST_INFO(b, t)  (((b) << 4) + ((t) & 0x0f))
    154141
    155142/**
    156143 * Symbol binding
    157144 */
    158 #define STB_LOCAL               0
    159 #define STB_GLOBAL              1
    160 #define STB_WEAK                2
    161 #define STB_LOPROC              13
    162 #define STB_HIPROC              15
     145#define STB_LOCAL   0
     146#define STB_GLOBAL  1
     147#define STB_WEAK    2
     148#define STB_LOPROC  13
     149#define STB_HIPROC  15
    163150
    164151/**
    165152 * Symbol types
    166153 */
    167 #define STT_NOTYPE              0
    168 #define STT_OBJECT              1
    169 #define STT_FUNC                2
    170 #define STT_SECTION             3
    171 #define STT_FILE                4
    172 #define STT_LOPROC              13
    173 #define STT_HIPROC              15
     154#define STT_NOTYPE   0
     155#define STT_OBJECT   1
     156#define STT_FUNC     2
     157#define STT_SECTION  3
     158#define STT_FILE     4
     159#define STT_LOPROC   13
     160#define STT_HIPROC   15
    174161
    175162/**
    176163 * Program segment types
    177164 */
    178 #define PT_NULL                 0
    179 #define PT_LOAD                 1
    180 #define PT_DYNAMIC              2
    181 #define PT_INTERP               3
    182 #define PT_NOTE                 4
    183 #define PT_SHLIB                5
    184 #define PT_PHDR                 6
    185 #define PT_LOPROC               0x70000000
    186 #define PT_HIPROC               0x7fffffff
     165#define PT_NULL     0
     166#define PT_LOAD     1
     167#define PT_DYNAMIC  2
     168#define PT_INTERP   3
     169#define PT_NOTE     4
     170#define PT_SHLIB    5
     171#define PT_PHDR     6
     172#define PT_LOPROC   0x70000000
     173#define PT_HIPROC   0x7fffffff
    187174
    188175/**
    189176 * Program segment attributes.
    190177 */
    191 #define PF_X    1
    192 #define PF_W    2
    193 #define PF_R    4
     178#define PF_X  1
     179#define PF_W  2
     180#define PF_R  4
    194181
    195182/**
     
    239226        elf_half e_shstrndx;
    240227};
     228
    241229struct elf64_header {
    242230        uint8_t e_ident[EI_NIDENT];
     
    256244};
    257245
    258 /*
     246/**
    259247 * ELF segment header.
    260248 * Segments headers are also known as program headers.
     
    270258        elf_word p_align;
    271259};
     260
    272261struct elf64_segment_header {
    273262        elf_word p_type;
     
    281270};
    282271
    283 /*
     272/**
    284273 * ELF section header
    285274 */
     
    296285        elf_word sh_entsize;
    297286};
     287
    298288struct elf64_section_header {
    299289        elf_word sh_name;
     
    309299};
    310300
    311 /*
     301/**
    312302 * ELF symbol table entry
    313303 */
     
    320310        elf_half st_shndx;
    321311};
     312
    322313struct elf64_symbol {
    323314        elf_word st_name;
     
    329320};
    330321
    331 #ifdef __32_BITS__
     322/*
     323 * ELF note segment entry
     324 */
     325struct elf32_note {
     326        elf_word namesz;
     327        elf_word descsz;
     328        elf_word type;
     329};
     330
     331/*
     332 * NOTE: namesz, descsz and type should be 64-bits wide (elf_xword)
     333 * per the 64-bit ELF spec. The Linux kernel however screws up and
     334 * defines them as Elf64_Word, which is 32-bits wide(!). We are trying
     335 * to make our core files compatible with Linux GDB target so we copy
     336 * the blunder here.
     337 */
     338struct elf64_note {
     339        elf_word namesz;
     340        elf_word descsz;
     341        elf_word type;
     342};
     343
     344#ifdef __32_BITS__
    332345typedef struct elf32_header elf_header_t;
    333346typedef struct elf32_segment_header elf_segment_header_t;
    334347typedef struct elf32_section_header elf_section_header_t;
    335348typedef struct elf32_symbol elf_symbol_t;
     349typedef struct elf32_note elf_note_t;
    336350#endif
     351
    337352#ifdef __64_BITS__
    338353typedef struct elf64_header elf_header_t;
     
    340355typedef struct elf64_section_header elf_section_header_t;
    341356typedef struct elf64_symbol elf_symbol_t;
     357typedef struct elf64_note elf_note_t;
    342358#endif
    343359
    344 extern char *elf_error(unsigned int rc);
    345 
    346360#endif
    347361
Note: See TracChangeset for help on using the changeset viewer.