[PATCH][GOLD] Add make_elf_object target hooks.

Ian Lance Taylor iant@google.com
Tue Aug 18 14:41:00 GMT 2009


"Doug Kwan (關振德)" <dougkwan@google.com> writes:

> +      gold_fatal(_("%s: unsupported ELF machine number %d"),
> +		 name.c_str(), ehdr.get_e_machine());
>        return NULL;

No need to call return after calling gold_fatal.


> +      obj->setup(ehdr);

It no longer makes sense for Object::setup to take an ehdr parameter.
It should take a target parameter, and avoid looking up the target
again.


> +  // make_elf_object hooks.  There are four versions of these for
> +  // different address sizes and endianities.
> +  
> +#ifdef HAVE_TARGET_32_LITTLE
> +  // Virtual functions which may be overriden by the child class.
> +  virtual Object*
> +  do_make_elf_object(const std::string& name, Input_file* input_file,
> +		     off_t offset, const elfcpp::Ehdr<32, false>& ehdr);
> +#endif
> +
> +#ifdef HAVE_TARGET_32_BIG
> +  // Virtual functions which may be overriden by the child class.
> +  virtual Object*
> +  do_make_elf_object(const std::string& name, Input_file* input_file,
> +		     off_t offset, const elfcpp::Ehdr<32, true>& ehdr);
> +#endif
> +
> +#ifdef HAVE_TARGET_64_LITTLE
> +  // Virtual functions which may be overriden by the child class.
> +  virtual Object*
> +  do_make_elf_object(const std::string& name, Input_file* input_file,
> +		     off_t offset, const elfcpp::Ehdr<64, false>& ehdr);
> +#endif
> +
> +#ifdef HAVE_TARGET_64_BIG
> +  // Virtual functions which may be overriden by the child class.
> +  virtual Object*
> +  do_make_elf_object(const std::string& name, Input_file* input_file,
> +		     off_t offset, const elfcpp::Ehdr<64, true>& ehdr);
> +#endif

Interesting problem.  I wonder if there is anything we can do to make
that easier to write.

Ian



More information about the Binutils mailing list