Hi,

FreeBSD has already defined the various Elf_ stuff for 32 and 64-bit targets.

Currently compilation in libbacktrace fails due to redefinition of these:

- Elf_Ehdr
- Elf_Sym
- Elf_Shdr

I 'fixed' this with ifndef'ing. See below.

Bootstrap passed.

Is something like this ok for trunk?

Thanks,
Andreas

Index: libbacktrace/elf.c
===================================================================
--- libbacktrace/elf.c  (revision 192293)
+++ libbacktrace/elf.c  (working copy)
@@ -131,6 +131,7 @@
 
 #define EI_NIDENT 16
 
+#ifndef __FreeBSD__
 typedef struct {
   unsigned char        e_ident[EI_NIDENT];     /* ELF "magic number" */
   Elf_Half     e_type;                 /* Identifies object file type */
@@ -147,6 +148,7 @@
   Elf_Half     e_shnum;                /* Section header table entry count */
   Elf_Half     e_shstrndx;             /* Section header string table index */
 } Elf_Ehdr;
+#endif /* __FreeBSD__  */
 
 #define EI_MAG0 0
 #define EI_MAG1 1
@@ -169,6 +171,7 @@
 
 #define EV_CURRENT 1
 
+#ifndef __FreeBSD__
 typedef struct {
   Elf_Word     sh_name;                /* Section name, index in string tbl */
   Elf_Word     sh_type;                /* Type of section */
@@ -181,6 +184,7 @@
   Elf_WXword   sh_addralign;           /* Section alignment */
   Elf_WXword   sh_entsize;             /* Entry size if section holds table */
 } Elf_Shdr;
+#endif /* __FreeBSD__  */
 
 #define SHN_LORESERVE  0xFF00          /* Begin range of reserved indices */
 #define SHN_XINDEX     0xFFFF          /* Section index is held elsewhere */
@@ -189,6 +193,8 @@
 #define SHT_STRTAB 3
 #define SHT_DYNSYM 11
 
+#ifndef __FreeBSD__
+
 #if BACKTRACE_ELF_SIZE == 32
 
 typedef struct
@@ -214,6 +220,7 @@
 } Elf_Sym;
 
 #endif /* BACKTRACE_ELF_SIZE != 32 */
+#endif /* __FreeBSD__  */
 
 #define STT_FUNC 2
 

Reply via email to