ariovistus committed 57fbde3

the deimos headers should be good now, except for libdwfl.
having linking problems

Comments (0)

Files changed (7)


 // fedora: elfutils-devel
 import std.stdint;
+import deimos.gelf;
 import deimos.elfutils.libebl;
+pragma(lib, "asm");
 /* Opaque type for the assembler context descriptor.  */
-alias AsmCtx AsmCtx_t;
+struct AsmCtx_t;
 /* Opaque type for a section.  */
-alias AsmScn AsmScn_t;
+struct AsmScn_t;
 /* Opaque type for a section group.  */
-alias AsmScnGrp AsmScnGrp_t;
+struct AsmScnGrp_t;
 /* Opaque type for a symbol.  */
-alias AsmSym AsmSym_t;
+struct AsmSym_t;
 /* Opaque type for the disassembler context descriptor.  */
-alias DisasmCtx DisasmCtx_t;
+struct DisasmCtx_t;
     /* Type used for callback functions to retrieve symbol name.  The
        symbol reference is in the section designated by the second parameter
        at an offset described by the first parameter.  The value is the
        third parameter.  */
-    int function(GElf_Addr, Elf32_Word, GElf_Addr, char **,
+    alias int function(GElf_Addr, Elf32_Word, GElf_Addr, char **,
             size_t *, void *) DisasmGetSymCB_t;
-/* Output function callback.  */
-int function(char *, size_t, void *) DisasmOutputCB_t;
+    /* Output function callback.  */
+    alias int function(char *, size_t, void *) DisasmOutputCB_t;
 /* Create output file and return descriptor for assembler context.  If
    TEXTP is true the output is an assembler format text file.
 /* Return error code of last failing function call.  This value is kept
    separately for each thread.  */
-int asm_errno (void);
+int asm_errno ();
 /* Return error string for ERROR.  If ERROR is zero, return error string
    for most recent error or NULL is none occurred.  If ERROR is -1 the
    behaviour is similar to the last case except that not NULL but a legal
    string is returned.  */
-const char *asm_errmsg (int __error);
+const(char*) asm_errmsg (int __error);
 /* Create context descriptor for disassembler.  */


 // license: gpl2
 import std.stdint;
-public import deimos.gelf;
+import deimos.gelf;
 /* Mode for the session.  */
 enum Dwarf_Cmd
 auto DWARF_END_ABBREV()(){ return(cast(Dwarf_Abbrev *) -1L);}
 /* Source code line information for CU.  */
-extern(C) struct Dwarf_Lines_s;
-typedef Dwarf_Lines_s Dwarf_Lines;
+struct Dwarf_Lines_s;
+alias Dwarf_Lines_s Dwarf_Lines;
 /* One source code line information.  */
 struct Dwarf_Line_s;
-typedef Dwarf_Line_s Dwarf_Line;
+alias Dwarf_Line_s Dwarf_Line;
 /* Source file information.  */
 struct Dwarf_Files_s;
-typedef Dwarf_Files_s Dwarf_Files;
+alias Dwarf_Files_s Dwarf_Files;
 /* One address range record.  */
 struct Dwarf_Arange_s;
-typedef Dwarf_Arange_s Dwarf_Arange;
+alias Dwarf_Arange_s Dwarf_Arange;
 /* Address ranges of a file.  */
 struct Dwarf_Aranges_s;
-typedef Dwarf_Aranges_s Dwarf_Aranges;
+alias Dwarf_Aranges_s Dwarf_Aranges;
 /* CU representation.  */
 struct Dwarf_CU;
 /* Macro information.  */
 struct Dwarf_Macro_s;
-typedef Dwarf_Macro_s Dwarf_Macro;
+alias Dwarf_Macro_s Dwarf_Macro;
 /* Attribute representation.  */
 struct Dwarf_Attribute
 /* Opaque type representing a frame state described by CFI.  */
 struct Dwarf_Frame_s;
-typedef Dwarf_Frame_s Dwarf_Frame;
+alias Dwarf_Frame_s Dwarf_Frame;
 /* Opaque type representing a CFI section found in a DWARF or ELF file.  */
 struct Dwarf_CFI_s;
-typedef Dwarf_CFI_s Dwarf_CFI;
+alias Dwarf_CFI_s Dwarf_CFI;
 /* Handle for debug sessions.  */
 struct Dwarf;


 // license: gpl2
 import deimos.elfutils.libdw;
+import deimos.gelf;
 import std.stdio: FILE;
+//pragma(lib, "dw");
 struct Dwfl;
 struct Dwfl_Module;
 struct Dwfl_Line;


 import deimos.gelf;
 import deimos.elfutils.libdw;
-alias ebl Ebl;
+struct Ebl;
     /* Get backend handle for object associated with ELF handle.  */
        handling.  */
     /* Return backend name.  */
-    const char *ebl_backend_name (Ebl *ebl);
+    const(char*) ebl_backend_name (Ebl *ebl);
     /* Return relocation type name.  */
-    const char *ebl_object_type_name (Ebl *ebl, int object,
+    const(char*) ebl_object_type_name (Ebl *ebl, int object,
             char *buf, size_t len);
 /* Return relocation type name.  */
-const char *ebl_reloc_type_name (Ebl *ebl, int reloc,
+const(char*) ebl_reloc_type_name (Ebl *ebl, int reloc,
         char *buf, size_t len);
 /* Check relocation type.  */
 bool ebl_gotpc_reloc_check (Ebl *ebl, int reloc);
 /* Return segment type name.  */
-const char *ebl_segment_type_name (Ebl *ebl, int segment,
+const(char*) ebl_segment_type_name (Ebl *ebl, int segment,
         char *buf, size_t len);
 /* Return section type name.  */
-const char *ebl_section_type_name (Ebl *ebl, int section,
+const(char*) ebl_section_type_name (Ebl *ebl, int section,
         char *buf, size_t len);
 /* Return section name.  */
-const char *ebl_section_name (Ebl *ebl, int section, int xsection,
+const(char*) ebl_section_name (Ebl *ebl, int section, int xsection,
         char *buf, size_t len,
-        const char *scnnames[], size_t shnum);
+        const(char*) scnnames[], size_t shnum);
 /* Return machine flag names.  */
-const char *ebl_machine_flag_name (Ebl *ebl, GElf_Word flags,
+const(char*) ebl_machine_flag_name (Ebl *ebl, GElf_Word flags,
         char *buf, size_t len);
 /* Check whether machine flag is valid.  */
         const GElf_Shdr *shdr, const char *name);
 /* Return symbol type name.  */
-const char *ebl_symbol_type_name (Ebl *ebl, int symbol,
+const(char*) ebl_symbol_type_name (Ebl *ebl, int symbol,
         char *buf, size_t len);
 /* Return symbol binding name.  */
-const char *ebl_symbol_binding_name (Ebl *ebl, int binding,
+const(char*) ebl_symbol_binding_name (Ebl *ebl, int binding,
         char *buf, size_t len);
 /* Return dynamic tag name.  */
-const char *ebl_dynamic_tag_name (Ebl *ebl, int64_t tag,
+const(char*) ebl_dynamic_tag_name (Ebl *ebl, int64_t tag,
         char *buf, size_t len);
 /* Check dynamic tag.  */
         GElf_Word flags2);
 /* Return symbolic representation of OS ABI.  */
-const char *ebl_osabi_name (Ebl *ebl, int osabi, char *buf, size_t len);
+const(char*) ebl_osabi_name (Ebl *ebl, int osabi, char *buf, size_t len);
 /* Return name of the note section type for a core file.  */
-const char *ebl_core_note_type_name (Ebl *ebl, uint32_t type, char *buf,
+const(char*) ebl_core_note_type_name (Ebl *ebl, uint32_t type, char *buf,
         size_t len);
 /* Return name of the note section type for an object file.  */
-const char *ebl_object_note_type_name (Ebl *ebl, uint32_t type,
+const(char*) ebl_object_note_type_name (Ebl *ebl, uint32_t type,
         char *buf, size_t len);
 /* Print information about object note if available.  */
 size_t ebl_strtaboffset (Ebl_Strent *se);
 /* Return the string associated with SE.  */
-const char *ebl_string (Ebl_Strent *se);
+const(char*) ebl_string (Ebl_Strent *se);
 /* ELF wide char string table handling.  */
 /* Non-register data items in core notes.  */
 struct Ebl_Core_Item
-    const char *name;		/* Printable identifier.  */
-    const char *group;		/* Identifier for category of related items.  */
+    const(char*) name;		/* Printable identifier.  */
+    const(char*) group;		/* Identifier for category of related items.  */
     Dwarf_Half offset;		/* Byte offset in note data.  */
     Dwarf_Half count;
     Elf_Type type;
+import std.stdio;
+import deimos.libelf;
+import deimos.gelf;
+import replace;
+template print_field(string x){
+    enum print_field = 
+        Replace!(q{writefln(printfmt, "$x", ehdr.$x);}, "$x", x);
+void main(){
+    assert(elf_version(EV_CURRENT) != EV_NONE, 
+            "elf library initialization failed");
+    auto f = File("udis_test");
+    auto e = elf_begin(f.fileno(), Elf_Cmd.ELF_C_READ, null);
+    assert(e);
+    auto ek = elf_kind(e);
+    switch(ek){
+        case Elf_Kind.ELF_K_ELF:
+            writeln("kurr?");
+            GElf_Ehdr ehdr;
+            assert(gelf_getehdr(e, &ehdr));
+            auto i = gelf_getclass(e);
+            assert(i != ELFCLASSNONE);
+            writefln("%s bit ELF object", i == ELFCLASS32 ? 32 : 64);
+            auto id = elf_getident(e,null);
+            assert(id);
+            writef("%3s e_ident[0 .. %1d] %7s", " ", EI_ABIVERSION, " ");
+            foreach(ii; 0 .. EI_ABIVERSION+1){
+                writef("\\x%x",id[ii]);
+            }
+            writeln();
+            enum printfmt = "    %-20s 0x%x";
+            mixin(print_field!("e_type"));
+            mixin(print_field!("e_machine"));
+            mixin(print_field!("e_entry"));
+            mixin(print_field!("e_phoff"));
+            mixin(print_field!("e_shoff"));
+            mixin(print_field!("e_flags"));
+            mixin(print_field!("e_ehsize"));
+            mixin(print_field!("e_phentsize"));
+            mixin(print_field!("e_shentsize"));
+            size_t n;
+            assert(elf_getshdrnum(e, &n)==0);
+            writefln(printfmt, "(shnum)", n);
+            assert(elf_getshdrstrndx(e, &n)==0);
+            writefln(printfmt, "(shstrndx)", n);
+            assert(elf_getphdrnum(e, &n)==0);
+            writefln(printfmt, "(phnum)", n);
+            break;
+        default: 
+            writeln("durr?");
+    }
+    elf_end(e);
+import deimos.elfutils.libasm;
+void main(){
+    asm_begin("abc", null,true);
+import deimos.elfutils.libebl;
+void main(){
+    ebl_openbackend (null);