[gold][patch] Small code refactoring

Cary Coutant ccoutant@google.com
Thu Feb 12 23:47:00 GMT 2009


> I was playing with gold and found a bit of code duplication. The
> attached patch removes it. I tested this with "make check" in the gold
> directory. Is there some other test I should do?

In general, it's a good idea to test both 32-bit and 64-bit builds,
but this change is small enough that one "make check" is sufficient.
I've occasionally also found bugs only with -g or only with -O, so I
usually test both of those as well. (I even found one that only showed
up with -O2 or -O3, but I'm not so rigorous as to test different opt
levels separately every time.)

>        * archive.cc (Archive::get_elf_object_for_member): Update for
>        new make_elf_object signature.
>        * object.cc (make_elf_object): Rename to make_elf_object2. Make it
>        static.
>        (make_elf_object): New.
>        * object.h (make_elf_object): Update signature.
>        * readsyms.cc (Read_symbols::do_read_symbols): Update for
>        new make_elf_object signature.
>        * testsuite/binary_unittest.cc (Sized_binary_test): Update for
>        new make_elf_object signature.
>        * testsuite/object_unittest.cc (Sized_object_test): Update for
>        new make_elf_object signature.

This looks reasonable to me, but I'm not a big fan of the name
"make_elf_object2". How about calling the new one something like
"recognize_and_make_elf_object"? Maybe Ian will have a better
suggestion.

-cary



More information about the Binutils mailing list