[gold] PATCH: Add R_X86_64_PC32_BND and R_X86_64_PLT32_BND

H.J. Lu hjl.tools@gmail.com
Mon Nov 18 17:25:00 GMT 2013


On Mon, Nov 18, 2013 at 9:15 AM, Ian Lance Taylor <iant@google.com> wrote:
> On Sun, Nov 17, 2013 at 10:35 AM, H.J. Lu <hongjiu.lu@intel.com> wrote:
>>
>>     Add R_X86_64_PC32_BND/R_X86_64_PLT32_BND suppor to gold
>>
>>     elfcpp/
>>
>>         * x86_64.h (R_X86_64_PC32_BND): New.
>>         (R_X86_64_PLT32_BND): Likewise.
>>
>>     gold/
>>
>>     2013-11-17  H.J. Lu  <hongjiu.lu@intel.com>
>>
>>         * x86_64.cc (Target_x86_64<size>::Scan::get_reference_flags):
>>         Handle R_X86_64_PC32_BND and R_X86_64_PLT32_BND just like
>>         R_X86_64_PC32 and R_X86_64_PLT32, respectively.
>>         (Target_x86_64<size>::Scan::local): Likewise.
>>         (Target_x86_64<size>::Scan::global): Likewise.
>>         (Target_x86_64<size>::Relocate::relocate): Likewise.
>>         (Target_x86_64<size>::Relocatable_size_for_reloc::get_size_for_reloc):
>>         Likewise.
>>         (Target_x86_64<size>::Scan::check_non_pic(): Handle
>>         R_X86_64_PC32_BND.
>>
>>         * testsuite/Makefile.am (check_PROGRAMS): Add
>>         exception_x86_64_bnd_test.
>>         (exception_x86_64_bnd_test_SOURCES): New macro.
>>         (exception_x86_64_bnd_test_DEPENDENCIES): Likewise.
>>         (exception_x86_64_bnd_test_LDFLAGS): Likewise.
>>         (exception_x86_64_bnd_test_LDADD): Likewise.
>>         (exception_x86_64_bnd_1.o): New rule.
>>         (exception_x86_64_bnd_2.o): Likewise.
>>         * testsuite/Makefile.in: Regenerated.
>
>
>>                         "overflow at runtime; recompile with -fPIC"),
>>                       (r_type == elfcpp::R_X86_64_32
>>                        ? "R_X86_64_32"
>> -                      : "R_X86_64_PC32"),
>> +                      : (r_type == elfcpp::R_X86_64_PC32
>> +                         ? "R_X86_64_PC32"
>> +                         : "R_X86_64_PC32_BND")),
>
> I would rather you did a small switch statement setting a local
> variable rather than nesting ?: expressions.

Like this?

        {
          const char *r_name;
          switch (r_type)
            {
            case elfcpp::R_X86_64_32:
              r_name = "R_X86_64_32";
              break;
            case elfcpp::R_X86_64_PC32:
              r_name = "R_X86_64_PC32";
              break;
            case elfcpp::R_X86_64_PC32_BND:
              r_name = "R_X86_64_PC32_BND";
              break;
            default:
              gold_unreachable();
              break;
            }
          object->error(_("requires dynamic %s reloc against '%s' "
                          "which may overflow at runtime; recompile "
                          "with -fPIC"),
                        r_name, gsym->name());
        }


Thanks.

-- 
H.J.



More information about the Binutils mailing list