This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
On Friday 14 July 2006 14:44, Victor Roman Archidona wrote: > I compiled by hand GCC and binutils (2.17), and when I compile some > file the output format is "UNIX - System V". I got this with > `readelf -h program`. > > The problem is that I need the default binary output must be "UNIX - > FreeBSD" and for now I can't fix it without help. freebsd tweaks the stock bfd elf64 code to change the EI_OSABI to ELFOSABI_FREEBSD ... that way the default 'elf-x86-64' target on amd64/freebsd systems actually outputs freebsd objects find attached a patch against cvs head to do this right (i think) ... note that ive never done any real bfd/gas hacking before, so this could be pretty wrong/incomplete ;) -mike
Attachment:
pgp00000.pgp
Description: PGP signature
--- bfd/config.bfd +++ bfd/config.bfd @@ -564,8 +564,8 @@ case "${targ}" in want64=true ;; x86_64-*-freebsd* | x86_64-*-kfreebsd*-gnu) - targ_defvec=bfd_elf64_x86_64_vec - targ_selvecs="bfd_elf32_i386_vec i386coff_vec bfd_efi_app_ia32_vec" + targ_defvec=bfd_elf64_x86_64_freebsd_vec + targ_selvecs="bfd_elf32_i386_freebsd_vec i386coff_vec bfd_efi_app_ia32_vec" want64=true ;; x86_64-*-netbsd* | x86_64-*-openbsd*) --- bfd/configure.in +++ bfd/configure.in @@ -709,6 +709,7 @@ do bfd_elf64_tradbigmips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; bfd_elf64_tradlittlemips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; bfd_elf64_x86_64_vec) tb="$tb elf64-x86-64.lo elf64.lo $elf"; target_size=64 ;; + bfd_elf64_x86_64_freebsd_vec) tb="$tb elf64-x86-64.lo elf64.lo $elf"; target_size=64 ;; bfd_mmo_vec) tb="$tb mmo.lo" target_size=64 ;; bfd_powerpc_pe_vec) tb="$tb pe-ppc.lo peigen.lo cofflink.lo" ;; bfd_powerpc_pei_vec) tb="$tb pei-ppc.lo peigen.lo cofflink.lo" ;; --- bfd/elf64-x86-64.c +++ bfd/elf64-x86-64.c @@ -3710,3 +3710,33 @@ static const struct bfd_elf_special_sect elf64_x86_64_hash_symbol #include "elf64-target.h" + +/* FreeBSD support. */ + +#undef TARGET_LITTLE_SYM +#define TARGET_LITTLE_SYM bfd_elf64_x86_64_freebsd_vec +#undef TARGET_LITTLE_NAME +#define TARGET_LITTLE_NAME "elf64-x86-64-freebsd" + +/* The kernel recognizes executables as valid only if they carry a + "FreeBSD" label in the ELF header. So we put this label on all + executables and (for simplicity) also all other object files. */ + +static void +elf_x86_64_post_process_headers (bfd *abfd, + struct bfd_link_info *info ATTRIBUTE_UNUSED) +{ + Elf_Internal_Ehdr *i_ehdrp; + + i_ehdrp = elf_elfheader (abfd); + + /* Put an ABI label supported by FreeBSD >= 4.1. */ + i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_FREEBSD; +} + +#undef elf_backend_post_process_headers +#define elf_backend_post_process_headers elf_x86_64_post_process_headers +#undef elf64_bed +#define elf64_bed elf64_x86_64_fbsd_bed + +#include "elf64-target.h" --- bfd/targets.c +++ bfd/targets.c @@ -669,6 +669,7 @@ extern const bfd_target bfd_elf64_sparc_ extern const bfd_target bfd_elf64_tradbigmips_vec; extern const bfd_target bfd_elf64_tradlittlemips_vec; extern const bfd_target bfd_elf64_x86_64_vec; +extern const bfd_target bfd_elf64_x86_64_freebsd_vec; extern const bfd_target bfd_mmo_vec; extern const bfd_target bfd_powerpc_pe_vec; extern const bfd_target bfd_powerpc_pei_vec; @@ -985,6 +986,7 @@ static const bfd_target * const _bfd_tar &bfd_elf64_tradbigmips_vec, &bfd_elf64_tradlittlemips_vec, &bfd_elf64_x86_64_vec, + &bfd_elf64_x86_64_freebsd_vec, &bfd_mmo_vec, #endif &bfd_powerpc_pe_vec, --- gas/config/tc-i386.c +++ gas/config/tc-i386.c @@ -5822,7 +5822,7 @@ md_parse_option (int c, char *arg) list = bfd_target_list (); for (l = list; *l != NULL; l++) - if (strcmp (*l, "elf64-x86-64") == 0) + if (strcmp (*l, ELF64_TARGET_FORMAT) == 0) { default_arch = "x86_64"; break; @@ -5978,7 +5978,7 @@ i386_target_format () object_64bit = 1; use_rela_relocations = 1; } - return flag_code == CODE_64BIT ? "elf64-x86-64" : ELF_TARGET_FORMAT; + return flag_code == CODE_64BIT ? ELF64_TARGET_FORMAT : ELF_TARGET_FORMAT; } #endif default: --- gas/config/tc-i386.h +++ gas/config/tc-i386.h @@ -55,6 +55,7 @@ extern unsigned long i386_mach (void); #ifdef TE_FreeBSD #define ELF_TARGET_FORMAT "elf32-i386-freebsd" +#define ELF64_TARGET_FORMAT "elf64-x86-64-freebsd" #elif defined (TE_VXWORKS) #define ELF_TARGET_FORMAT "elf32-i386-vxworks" #endif @@ -63,6 +64,10 @@ extern unsigned long i386_mach (void); #define ELF_TARGET_FORMAT "elf32-i386" #endif +#ifndef ELF64_TARGET_FORMAT +#define ELF64_TARGET_FORMAT "elf64-x86-64" +#endif + #if ((defined (OBJ_MAYBE_COFF) && defined (OBJ_MAYBE_AOUT)) \ || defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)) extern const char *i386_target_format PARAMS ((void));
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |