[PATCH, x86_64] Remove R_X86_64_PC32_BND and R_X86_64_PLT32_BND

H.J. Lu hjl.tools@gmail.com
Fri Nov 14 14:46:00 GMT 2014


On Fri, Nov 14, 2014 at 6:34 AM, Zamyatin, Igor <igor.zamyatin@intel.com> wrote:
> Hi!
>
> It is appeared that for Intel MPX R_X86_64_*_BND relocations are not enough in case of indirect calls like eg in the following example:
>
> foo:
>          movq    fp@GOTPCREL(%rip), %rax
>          bnd jmp     *(%rax)
>          .globl  fp
>          .section        .data.rel,"aw",@progbits
>          .align 8
>          .type   fp, @object
>          .size   fp, 8
>  fp:
>          .quad   memcpy
>
> There will be no R_X86_64_*_BND relocation but anyway linker needs to
> generate extended PLT entry for memcpy.
>
> The given patch contains changes that create separate linker option (-z bndplt) which forces
> linker to create extended PLT entry for any call (this option will be passed to linker when compilation is in MPX mode).
> Thus we can omit R_X86_64_*_BND relocations completely. (They left in the code just for backward compatibility).
>
> MPX ABI changed accordingly (https://github.com/hjl-tools/x86-64-psABI/tree/hjl/mpx/master).
>
> Thanks,
> Igor
>
> Changelogs:
>
> bfd/ChangeLog
>
> 2014-11-14  Igor Zamyatin  <igor.zamyatin@intel.com>
>
>         * elf64-x86-64.c (elf_x86_64_check_relocs): MPX PLT is now supported
>         for R_X86_64_PC32, R_X86_64_PLT32, R_X86_64_32 and R_X86_64_64 when
>         bndplt option is specified.
>
>
> include/ChangeLog
>
> 2014-11-14  Igor Zamyatin  <igor.zamyatin@intel.com>
>
>         * bfdlink.h (struct bfd_link_info): New field bndplt.
>
> ld/ChangeLog
>
> 2014-11-14  Igor Zamyatin  <igor.zamyatin@intel.com>
>
>         * emulparams/elf_x86_64.sh: Set BNDPLT for x86_64.
>         * emultempl/elf32.em: Handle bndplt option and add description for it.
>         * ld.texinfo: Add description for bndplt.
>         * testsuite/ld-x86-64/bnd-ifunc-1.d: Add bndplt option.
>         * testsuite/ld-x86-64/bnd-ifunc-2.d: Ditto.
>         * testsuite/ld-x86-64/bnd-plt-1.d: Ditto. Update dissassembly
>         sections.
>         * testsuite/ld-x86-64/mpx.exp: Handle mpx3 and mpx4 tests.
>         * testsuite/ld-x86-64/mpx3.dd: New file.
>         * testsuite/ld-x86-64/mpx3a.s: New file.
>         * testsuite/ld-x86-64/mpx3b.s: New file.
>         * testsuite/ld-x86-64/mpx4.dd: New file.
>         * testsuite/ld-x86-64/mpx4a.s: New file.
>         * testsuite/ld-x86-64/mpx4b.s: New file.
>

Looks good.

> diff --git a/ld/ld.texinfo b/ld/ld.texinfo
> index 5762dc6..eaa925d 100644
> --- a/ld/ld.texinfo
> +++ b/ld/ld.texinfo
> @@ -1104,6 +1104,10 @@ Specify a stack size for in an ELF @code{PT_GNU_STACK} segment.
>  Specifying zero will override any default non-zero sized
>  @code{PT_GNU_STACK} segment creation.
>
> +@item bndplt
> +Always generate BND prefix in PLT entries.
> +Enabled for Linux/x86_64.

Please use

Always generate BND prefix in PLT entries.  Supported for Linux/x86-64.

>  @end table
>

Please add your ChangeLog entries to ChangeLog files and use

# git format-patch origin/master

to regenerate the patch and post it so that I can do

# git am
# git rebase

to apply it.

Thanks.


-- 
H.J.



More information about the Binutils mailing list