diff options
author | Ian Lance Taylor <ian@airs.com> | 2011-06-28 22:25:14 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@airs.com> | 2011-06-28 22:25:14 +0000 |
commit | 200b2bb9e8930d9d47fa5f378cf595328ee9c9bc (patch) | |
tree | 57dd95b99e99a1306e2503f90771d01f1e71d518 /gold/target.cc | |
parent | b3ce541e970466431bf6abfa8ad58424a1d1a7ec (diff) | |
download | gdb-200b2bb9e8930d9d47fa5f378cf595328ee9c9bc.zip gdb-200b2bb9e8930d9d47fa5f378cf595328ee9c9bc.tar.gz gdb-200b2bb9e8930d9d47fa5f378cf595328ee9c9bc.tar.bz2 |
* target.h (class Target): Add osabi_ field.
(Target::osabi): New function.
(Target::set_osabi): New function.
(Target::Target): Initialize osabi_.
(Target::do_adjust_elf_header): Make pure virtual.
(Sized_target::do_adjust_elf_header): Declare.
* target.cc (Sized_target::do_adjust_elf_header): New function.
(class Sized_target): Instantiate all versions.
* freebsd.h (class Target_freebsd): Remove.
(Target_selector_freebsd::do_recognize): Call set_osabi on
Target.
(Target_selector_freebsd::do_recognize_by_name): Likewise.
(Target_selector_freebsd::set_osabi): Remove.
* i386.cc (class Target_i386): Inherit from Sized_target rather
than Target_freebsd.
* x86_64.cc (class Target_x86_64): Likewise.
Diffstat (limited to 'gold/target.cc')
-rw-r--r-- | gold/target.cc | 49 |
1 files changed, 47 insertions, 2 deletions
diff --git a/gold/target.cc b/gold/target.cc index 0e329cd..4a7af83 100644 --- a/gold/target.cc +++ b/gold/target.cc @@ -1,6 +1,6 @@ -// target.cc +// target.cc -- target support for gold. -// Copyright 2009, 2010 Free Software Foundation, Inc. +// Copyright 2009, 2010, 2011 Free Software Foundation, Inc. // Written by Doug Kwan <dougkwan@google.com>. // This file is part of gold. @@ -200,4 +200,49 @@ Target::set_view_to_nop(unsigned char* view, section_size_type view_size, } } +// Class Sized_target. + +// Set the EI_OSABI field of the ELF header if requested. + +template<int size, bool big_endian> +void +Sized_target<size, big_endian>::do_adjust_elf_header(unsigned char* view, + int len) const +{ + elfcpp::ELFOSABI osabi = this->osabi(); + if (osabi != elfcpp::ELFOSABI_NONE) + { + gold_assert(len == elfcpp::Elf_sizes<size>::ehdr_size); + + elfcpp::Ehdr<size, false> ehdr(view); + unsigned char e_ident[elfcpp::EI_NIDENT]; + memcpy(e_ident, ehdr.get_e_ident(), elfcpp::EI_NIDENT); + + e_ident[elfcpp::EI_OSABI] = osabi; + + elfcpp::Ehdr_write<size, false> oehdr(view); + oehdr.put_e_ident(e_ident); + } +} + +#ifdef HAVE_TARGET_32_LITTLE +template +class Sized_target<32, false>; +#endif + +#ifdef HAVE_TARGET_32_BIG +template +class Sized_target<32, true>; +#endif + +#ifdef HAVE_TARGET_64_LITTLE +template +class Sized_target<64, false>; +#endif + +#ifdef HAVE_TARGET_64_BIG +template +class Sized_target<64, true>; +#endif + } // End namespace gold. |