Message ID | 50757BE9.4080002@fgznet.ch |
---|---|
State | New |
Headers | show |
On Wed, Oct 10, 2012 at 6:45 AM, Andreas Tobler <andreast-list@fgznet.ch> wrote: > > 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. I don't think that is the right patch. I think the right patch is to unconditionally rename the structs in libbacktrace/elf.c. Do you want to try a patch along those lines? I suppose we might want to rename the types as well. It's nice to use the same names as the ELF ABI, but I guess that conflicts with system header files are too likely. Ian
On 10.10.12 17:36, Ian Lance Taylor wrote: > On Wed, Oct 10, 2012 at 6:45 AM, Andreas Tobler <andreast-list@fgznet.ch> wrote: >> >> 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. > > I don't think that is the right patch. I think the right patch is to > unconditionally rename the structs in libbacktrace/elf.c. Do you want > to try a patch along those lines? Np. > I suppose we might want to rename the types as well. It's nice to use > the same names as the ELF ABI, but I guess that conflicts with system > header files are too likely. On the quick I did it this way, etc. - const Elf_Shdr *strtab_shdr; + const elf_shdr *strtab_shdr; If we keep small letters then we're consistent with the other variables in this file. Or do you prefer some fancier names? Andreas
On Wed, Oct 10, 2012 at 12:30 PM, Andreas Tobler <andreast-list@fgznet.ch> wrote: > On 10.10.12 17:36, Ian Lance Taylor wrote: >> >> On Wed, Oct 10, 2012 at 6:45 AM, Andreas Tobler <andreast-list@fgznet.ch> >> wrote: >>> >>> >>> 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. >> >> >> I don't think that is the right patch. I think the right patch is to >> unconditionally rename the structs in libbacktrace/elf.c. Do you want >> to try a patch along those lines? > > > Np. > > >> I suppose we might want to rename the types as well. It's nice to use >> the same names as the ELF ABI, but I guess that conflicts with system >> header files are too likely. > > > On the quick I did it this way, etc. > > - const Elf_Shdr *strtab_shdr; > + const elf_shdr *strtab_shdr; > > If we keep small letters then we're consistent with the other variables in > this file. > > Or do you prefer some fancier names? Thanks. I decided that starting with b_elf would be safer. I wrote the patch and committed it to mainline. Bootstrapped and ran libbacktrace testsuite on x86_64-unknown-linux-gnu. Please let me know if there are still problems on FreeBSD. Ian 2012-10-10 Ian Lance Taylor <iant@google.com> * elf.c: Rename all Elf typedefs to start with b_elf, and be all lower case.
On 10.10.12 22:00, Ian Lance Taylor wrote: > On Wed, Oct 10, 2012 at 12:30 PM, Andreas Tobler > <andreast-list@fgznet.ch> wrote: >> On 10.10.12 17:36, Ian Lance Taylor wrote: >>> >>> On Wed, Oct 10, 2012 at 6:45 AM, Andreas Tobler <andreast-list@fgznet.ch> >>> wrote: >>>> >>>> >>>> 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. >>> >>> >>> I don't think that is the right patch. I think the right patch is to >>> unconditionally rename the structs in libbacktrace/elf.c. Do you want >>> to try a patch along those lines? >> >> >> Np. >> >> >>> I suppose we might want to rename the types as well. It's nice to use >>> the same names as the ELF ABI, but I guess that conflicts with system >>> header files are too likely. >> >> >> On the quick I did it this way, etc. >> >> - const Elf_Shdr *strtab_shdr; >> + const elf_shdr *strtab_shdr; >> >> If we keep small letters then we're consistent with the other variables in >> this file. >> >> Or do you prefer some fancier names? > > Thanks. I decided that starting with b_elf would be safer. I wrote > the patch and committed it to mainline. Bootstrapped and ran > libbacktrace testsuite on x86_64-unknown-linux-gnu. Please let me > know if there are still problems on FreeBSD. Great. I need to buy a faster machine :) This patch works so far. Bootstrap restarted. Thanks a lot. 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