This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] [BINUTILS] [MICROBLAZE] PIC Data Text Relative


Dears,

Please find below the patch for microblaze new pic data text relative option.


Description:
This branch is regarding a new implemented feature in GCC Microblaze
that allows Position Independent Code to run using Data Text Relative
addressing instead of using Global Offset Table.

Its aim was to make 'PIC' more efficient and flexible as elf size
excess/ performance overhead were noticed when using GOT due to the
indirect addressing.
The change was tested with the dhrystone benchmark on a real Hardware
(Xilinx FPGA Spartan 6) and the test report went successfully for all
optimization levels.

Indeed, Microblaze does not support PC-relative addressing in Hardware like ARM.
The idea was to store the start address of current text section in
'r20' instead of GOT, in the function prologue. Correspondingly, data
references will be an offset from the original reference value to the
start of text thus being added to the 'r20' base register will resolve
the actual address.

Henceforth, 2 new relocations have been created:
- 'R_MICROBLAZE_TEXTPCREL_64': resolves offset of current PC to start
of text in order to set r20
- 'R_MICROBLAZE_TEXTREL_64': resolves offset of mentioned data
reference to start of text

Accordingly, both assembler and linker (binutils) have been adapted.

For extra details:
https://github.com/andrewsadek/microblaze-pic-data-text-rel/blob/pic_data_text_rel/README.md

Change Log:
2018-03-22 Andrew Sadek  <andrew.sadek.se@gmail.com>

    Microblaze Target: PIC data text relative
    * include/elf/microblaze.h (Add 3 new relocations):
'R_MICROBLAZE_TEXTPCREL_64', 'R_MICROBLAZE_TEXTREL_64'
    and 'R_MICROBLAZE_TEXTREL_32_LO' for relax function.
    * bfd/bfd-in2.h, bfd/libbfd.h (2 new BFD relocations):
'BFD_RELOC_MICROBLAZE_64_TEXTPCREL' +
'BFD_RELOC_MICROBLAZE_64_TEXTPCREL'
    * bfd/elf32-microblaze.c (Handle new relocs): define 'HOWTO' of 3
new relocs and handle them in both relocate
    and relax functions.
    (microblaze_elf_reloc_type_lookup): add mapping between for new bfd relocs.
    (microblaze_bfd_write_branch_absolute_value_64): replace relative
branch with absolute in case 'adjust_insn_abs_refs' is true
    (microblaze_bfd_revert_base_reg_value_64): revert base register
from r20 to r0 in case 'adjust_insn_abs_refs' is true
    (microblaze_elf_relocate_section): Handle new relocs in case of
elf relocation.
    (microblaze_elf_relax_section): Handle new relocs for elf relaxation.
    * gas/config/tc-microblaze.c (Handle new relocs directives in
assembler): Handle new relocs from compiler output.
    (imm_types): add new imm types for data text relative addressing
'TEXT_OFFSET', 'TEXT_PC_OFFSET'
    (md_convert_frag): conversion for
'BFD_RELOC_MICROBLAZE_64_TEXTPCREL' ,
'BFD_RELOC_MICROBLAZE_64_TEXTPCREL'
    (md_apply_fix): apply fix for 'BFD_RELOC_MICROBLAZE_64_TEXTPCREL'
, 'BFD_RELOC_MICROBLAZE_64_TEXTPCREL'
    (md_estimate_size_before_relax): estimate size for
'BFD_RELOC_MICROBLAZE_64_TEXTPCREL' ,
'BFD_RELOC_MICROBLAZE_64_TEXTPCREL'
    (tc_gen_reloc): generate relocations for
'BFD_RELOC_MICROBLAZE_64_TEXTPCREL' ,
'BFD_RELOC_MICROBLAZE_64_TEXTPCREL'
    Add new linker options for static linking: adjust-insn-abs-refs,
disable-multiple-abs-defs
    * ld/lexsup.c (Add 2 ld options):
    (ld_options): add adjust-insn-abs-refs, disable-multiple-abs-defs
@ 'ld_options' array
    (parse_args): parse options and pass flags to 'link_info' struct.
    * ld/ldlex.h (Add 2 enums): add new enums @ 'option_values' enum.
    * include/bfdlink.h (Add 2 flags): Add new flags @ 'bfd_link_info' struct.
    * ld/main.c: Initialize flags with false @ 'main'. Handle
disable-multiple-abs-defs
    @ 'mutiple_definition'.


Patch:
----------
Actually, I found that gmail transforms tabs to spaces even plain text
mode, also I can not attach the patch as I receive error from
sourceware server, so for now kindly find the patch in the link
below,, if you have solution for that please advise.

https://github.com/andrewsadek/microblaze-pic-data-text-rel/blob/pic_data_text_rel/PATCH_BUNDLE/binutils.patch

-- 

Andrew


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]