)]}'
{
  "commit": "0699f2d795cdb4bc4db2bcf438291ec09d21f0da",
  "tree": "597c645a7be8beeac977ec7ec64f75134b8cf0e1",
  "parents": [
    "3a117c5887312afb3f1567f1cae3316872d575f4"
  ],
  "author": {
    "name": "Lifang Xia",
    "email": "lifang_xia@linux.alibaba.com",
    "time": "Thu Oct 27 11:19:15 2022 +0800"
  },
  "committer": {
    "name": "Nelson Chu",
    "email": "nelson@rivosinc.com",
    "time": "Fri Apr 21 15:47:47 2023 +0800"
  },
  "message": "RISC-V: Optimize relaxation of gp with max_alignment.\n\nThis should be the first related issue, which posted in riscv-gnu-toolchain,\nhttps://github.com/riscv-collab/riscv-gnu-toolchain/issues/497\n\nIf the output sections are not between gp and the symbol, then their alignments\nshouldn\u0027t affect the gp relaxation.  However, this patch improves this idea\neven more, it limits the range to the gp+-2k, which means only the output\nsection which are in the [gp-2K, gp+2K) range need to be considered.\n\nEven if the output section candidates may be different for each relax passes,\nthe symbol that can be relaxed ar this round will not be truncated at next\nround.  That is because this round you can do relaxation which means that the\nsection where the symbol is located is within the [gp-2K, gp+2K) range, so all\nthe output section alignments between them should be considered.  In other\nwords, if the alignments between them may cause truncated, then we should\nalready preserve the size and won\u0027t do the gp relaxation this time.\n\nThis patch can resolve the github issue which mentioned above, and also passed\nall gcc/binutils regressions of riscv-gnu-toolchain, so should be worth and\nsafe enough to commit.\n\nOriginally, this patch also do the same optimization for the call relaxations,\nhttps://sourceware.org/pipermail/binutils/2022-October/123918.html\nBut just in case there is something that has not been considered, we only\ndeal with the gp relaxation at this time.\n\nbfd/\n\t* elfnn-riscv.c (riscv_elf_link_hash_table): Added new bfd_vma,\n\tmax_alignment_for_gp.  It is used to record the maximum alignment of\n\tthe output sections, which are in the [gp-2K, gp+2k) range.\n\t(riscv_elf_link_hash_table_create): Init max_alignment_for_gp to -1.\n\t(_bfd_riscv_get_max_alignment): Added new parameter, gp.  If gp is\n\tzero, then all the output section alignments are possible candidates;\n\tOtherwise, only the output sections which are in the [gp-2K, gp+2K)\n\trange need to be considered.\n\t(_bfd_riscv_relax_lui): Called _bfd_riscv_get_max_alignment with the\n\tnon-zero gp if the max_alignment_for_gp is -1.\n\t(_bfd_riscv_relax_pc): Likewise.\n\t(_bfd_riscv_relax_section): Record the first input section, so that\n\twe can reset the max_alignment_for_gp for each repeated relax passes.\nld/\n\t* testsuite/ld-riscv-elf/ld-riscv-elf.exp: Updated.\n\t* testsuite/ld-riscv-elf/relax-max-align-gp.*: New testcase.  It fails\n\twithout this patch.\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "0dd9b27c8ae983bf8069bd408e271b98ceae2406",
      "old_mode": 33188,
      "old_path": "bfd/elfnn-riscv.c",
      "new_id": "e90e36b58bbbd2da875a37678d609f5fa9d4d189",
      "new_mode": 33188,
      "new_path": "bfd/elfnn-riscv.c"
    },
    {
      "type": "modify",
      "old_id": "43572c5286bc6f30f55334f5157401edb39abcb5",
      "old_mode": 33188,
      "old_path": "ld/testsuite/ld-riscv-elf/ld-riscv-elf.exp",
      "new_id": "9e103b283f7d056b8a39d03d38ba1ecff4070897",
      "new_mode": 33188,
      "new_path": "ld/testsuite/ld-riscv-elf/ld-riscv-elf.exp"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "637de426ee4a418c22367e9dfaae11a7b095b23e",
      "new_mode": 33188,
      "new_path": "ld/testsuite/ld-riscv-elf/relax-max-align-gp.d"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "ce3da21e7f4023840237ca4b350dc758fdfdbfd2",
      "new_mode": 33188,
      "new_path": "ld/testsuite/ld-riscv-elf/relax-max-align-gp.s"
    }
  ]
}
