⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 elf.h

📁 eCos/RedBoot for勤研ARM AnywhereII(4510) 含全部源代码
💻 H
📖 第 1 页 / 共 3 页
字号:
#define ELF32_ST_VISIBILITY(o)  ((o)&0x3)
#define ELF64_ST_VISIBILITY(o)  ((o)&0x3)

// -------------------------------------------------------------------------
/* Symbol Binding - ELF32_ST_BIND - st_info */

#define STB_LOCAL       0               /* Local symbol */
#define STB_GLOBAL      1               /* Global symbol */
#define STB_WEAK        2               /* like global - lower precedence */
#define STB_NUM         3               /* number of symbol bindings */
#define STB_LOOS        10              /* reserved range for OS */
#define STB_HIOS        12              /*  specific symbol bindings */
#define STB_LOPROC      13              /* reserved range for processor */
#define STB_HIPROC      15              /*  specific symbol bindings */

// -------------------------------------------------------------------------
/* Symbol type - ELF32_ST_TYPE - st_info */

#define STT_NOTYPE      0               /* not specified */
#define STT_OBJECT      1               /* data object */
#define STT_FUNC        2               /* function */
#define STT_SECTION     3               /* section */
#define STT_FILE        4               /* file */
#define STT_COMMON      5               /* common block */
#define STT_NUM         6               /* number of symbol types */
#define STT_LOOS        10              /* reserved range for OS */
#define STT_HIOS        12              /*  specific symbol types */
#define STT_LOPROC      13              /* reserved range for processor */
#define STT_HIPROC      15              /*  specific symbol types */

// -------------------------------------------------------------------------
// symbol visibility in st_other

#define STV_DEFAULT     0               /* default to binding type */
#define STV_INTERNAL    1               /* processor specific */
#define STV_HIDDEN      2               /* invisible */
#define STV_PROTECTED   3               /* non-premptable */

// -------------------------------------------------------------------------
// 32 bit relocation records

/* Relocation entry with implicit addend */
typedef struct 
{
        Elf32_Addr      r_offset;       /* offset of relocation */
        Elf32_Word      r_info;         /* symbol table index and type */
} Elf32_Rel;

/* Relocation entry with explicit addend */
typedef struct 
{
        Elf32_Addr      r_offset;       /* offset of relocation */
        Elf32_Word      r_info;         /* symbol table index and type */
        Elf32_Sword     r_addend;
} Elf32_Rela;

/* Extract relocation info - r_info */
#define ELF32_R_SYM(i)          ((i) >> 8)
#define ELF32_R_TYPE(i)         ((unsigned char) (i))
#define ELF32_R_INFO(s,t)       (((s) << 8) + (unsigned char)(t))

// -------------------------------------------------------------------------
// 64 bit equivalents of above structures and macros.

typedef struct {
        Elf64_Addr      r_offset;       /* where to do it */
        Elf64_Xword     r_info;         /* index & type of relocation */
} Elf64_Rel;

typedef struct {
        Elf64_Addr      r_offset;       /* where to do it */
        Elf64_Xword     r_info;         /* index & type of relocation */
        Elf64_Sxword    r_addend;       /* adjustment value */
} Elf64_RelA;

#define ELF64_R_SYM(info)       ((info) >> 32)
#define ELF64_R_TYPE(info)      ((info) & 0xFFFFFFFF)
#define ELF64_R_INFO(s,t)       (((s) << 32) + (u_int32_t)(t))

// -------------------------------------------------------------------------
/* Program Header */

typedef struct {
    Elf32_Word  p_type;         /* segment type */
    Elf32_Off   p_offset;       /* segment offset */
    Elf32_Addr  p_vaddr;        /* virtual address of segment */
    Elf32_Addr  p_paddr;        /* physical address - ignored? */
    Elf32_Word  p_filesz;       /* number of bytes in file for seg. */
    Elf32_Word  p_memsz;        /* number of bytes in mem. for seg. */
    Elf32_Word  p_flags;        /* flags */
    Elf32_Word  p_align;        /* memory alignment */
} Elf32_Phdr;

typedef struct {
    Elf64_Word  p_type;         /* entry type */
    Elf64_Word  p_flags;        /* flags */
    Elf64_Off   p_offset;       /* offset */
    Elf64_Addr  p_vaddr;        /* virtual address */
    Elf64_Addr  p_paddr;        /* physical address */
    Elf64_Xword p_filesz;       /* file size */
    Elf64_Xword p_memsz;        /* memory size */
    Elf64_Xword p_align;        /* memory & file alignment */
} Elf64_Phdr;

// -------------------------------------------------------------------------
/* Segment types - p_type */

#define PT_NULL         0               /* unused */
#define PT_LOAD         1               /* loadable segment */
#define PT_DYNAMIC      2               /* dynamic linking section */
#define PT_INTERP       3               /* the RTLD */
#define PT_NOTE         4               /* auxiliary information */
#define PT_SHLIB        5               /* reserved - purpose undefined */
#define PT_PHDR         6               /* program header */
#define PT_NUM          7               /* Number of segment types */
#define PT_LOOS         0x60000000      /* reserved range for OS */
#define PT_HIOS         0x6fffffff      /*  specific segment types */
#define PT_LOPROC       0x70000000      /* reserved range for processor */
#define PT_HIPROC       0x7fffffff      /*  specific segment types */

// -------------------------------------------------------------------------
/* Segment flags - p_flags */

#define PF_X            0x1             /* Executable */
#define PF_W            0x2             /* Writable */
#define PF_R            0x4             /* Readable */
#define PF_MASKOS       0x0ff00000      /* reserved bits for OS */
                                        /*  specific segment flags */
#define PF_MASKPROC     0xf0000000      /* reserved bits for processor */
                                        /*  specific segment flags */

// -------------------------------------------------------------------------
/* Dynamic structure */

typedef struct {
    Elf32_Sword         d_tag;  /* controls meaning of d_val */
    union {
        Elf32_Word      d_val;  /* Multiple meanings - see d_tag */
        Elf32_Addr      d_ptr;  /* program virtual address */
    } d_un;
} Elf32_Dyn;

extern Elf32_Dyn        _DYNAMIC[];     /* XXX not 64-bit clean */

typedef struct {
    Elf64_Sxword        d_tag;  /* controls meaning of d_val */
    union {
        Elf64_Xword     d_val;
        Elf64_Addr      d_ptr;
    } d_un;
} Elf64_Dyn;

// -------------------------------------------------------------------------
/* Dynamic Array Tags - d_tag */

#define DT_NULL         0               /* marks end of _DYNAMIC array */
#define DT_NEEDED       1               /* string table offset of needed lib */
#define DT_PLTRELSZ     2               /* size of relocation entries in PLT */
#define DT_PLTGOT       3               /* address PLT/GOT */
#define DT_HASH         4               /* address of symbol hash table */
#define DT_STRTAB       5               /* address of string table */
#define DT_SYMTAB       6               /* address of symbol table */
#define DT_RELA         7               /* address of relocation table */
#define DT_RELASZ       8               /* size of relocation table */
#define DT_RELAENT      9               /* size of relocation entry */
#define DT_STRSZ        10              /* size of string table */
#define DT_SYMENT       11              /* size of symbol table entry */
#define DT_INIT         12              /* address of initialization func. */
#define DT_FINI         13              /* address of termination function */
#define DT_SONAME       14              /* string table offset of shared obj */
#define DT_RPATH        15              /* string table offset of library
                                           search path */
#define DT_SYMBOLIC     16              /* start sym search in shared obj. */
#define DT_REL          17              /* address of rel. tbl. w addends */
#define DT_RELSZ        18              /* size of DT_REL relocation table */
#define DT_RELENT       19              /* size of DT_REL relocation entry */
#define DT_PLTREL       20              /* PLT referenced relocation entry */
#define DT_DEBUG        21              /* bugger */
#define DT_TEXTREL      22              /* Allow rel. mod. to unwritable seg */
#define DT_JMPREL       23              /* add. of PLT's relocation entries */
#define DT_BIND_NOW     24              /* Bind now regardless of env setting */
#define DT_INIT_ARRAY   25              /* init array address */
#define DT_FINI_ARRAY   26              /* fini array address */
#define DT_INIT_ARRAYSZ 27              /* init array size */
#define DT_FINI_ARRAYSZ 28              /* fini array size */
#define DT_RUNPATH      29              /* library search path */
#define DT_FLAGS        30              /* flags */
#define DT_ENCODING     32              /* encoding rules start here */
#define DT_PREINIT_ARRAY 32             /* preinit array address */
#define DT_PREINIT_ARRAYSZ 33           /* preinit array size */
#define DT_NUM          26              /* Number used. */
#define DT_LOOS         0x60000000      /* reserved range for OS */
#define DT_HIOS         0x6fffffff      /*  specific dynamic array tags */
#define DT_LOPROC       0x70000000      /* reserved range for processor */
#define DT_HIPROC       0x7fffffff      /*  specific dynamic array tags */

// -------------------------------------------------------------------------
// Values for DT_FLAGS entry

#define DF_ORIGIN       0x1             /* Uses $ORIGIN substitution string */
#define DF_SYMBOLIC     0x2             /* search for symbols here first */
#define DF_TEXTREL      0x4             /* text may be relocatable */
#define DF_BIND_NOW     0x8             /* bind references now, dammit */

// -------------------------------------------------------------------------
/* Note Definitions */

typedef struct {
    Elf32_Word namesz;
    Elf32_Word descsz;
    Elf32_Word type;
} Elf32_Note;

typedef struct {
    Elf64_Word namesz;
    Elf64_Word descsz;
    Elf64_Word type;
} Elf64_Note;

// -------------------------------------------------------------------------
// Hash table structure
// The same structure is used by both 32 and 64 bit formats

typedef struct {
    Elf32_Word          nbucket;        /* number of buckets */
    Elf32_Word          nchain;         /* number of chains */

    /* The buckets follow this structure in memory and the chains
       follow those. */
} Elf_Hash;

// -------------------------------------------------------------------------
#endif // ifndef CYGONCE_REDBOOT_ELF_H
// EOF elf.h

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -