)]}'
{
  "commit": "68f5cb38c27699e9b4840f22596ede96762c4796",
  "tree": "52ae401451ef7d1ad7d84e745c4bc916e529a703",
  "parents": [
    "509dbc2bf167f9afb42d8b20200b529acc0d1ee9"
  ],
  "author": {
    "name": "Maciej W. Rozycki",
    "email": "macro@orcam.me.uk",
    "time": "Sat Jul 12 01:25:53 2025 +0100"
  },
  "committer": {
    "name": "Maciej W. Rozycki",
    "email": "macro@orcam.me.uk",
    "time": "Sat Jul 12 01:25:53 2025 +0100"
  },
  "message": "PR 19977: MIPS: Add missing pairing for REL PCHI/PCLO relocations\n\nJust as with all HI/LO 16-bit partial relocations the newly-introduced\nMIPSr6 PC-relative R_MIPS_PCHI16 and R_MIPS_PCLO16 relocations require\npairing for correct borrow propagation from the low part to the high\npart with REL targets, another case for PR 19977.\n\nUnlike with absolute relocation, there is a complication here in that\nboth parts represent a calculation that is relative to the PC at the\nindividual relocation\u0027s location rather than both referring to the\nlocation of the R_MIPS_PCHI16 relocation, normally applied to an AUIPC\ninstruction, the location of which is used for the run-time calculation\nexecuted by hardware.\n\nTo take this semantics into account, the addend of the R_MIPS_PCLO16\nrelocation matching a given R_MIPS_PCHI16 relocation is expected to be\nadjusted in the source assembly file for the distance between the two\nrelocations in a single pair, so that once both relocations have been\ncalculated by the linker, the expression calculated at run time is such\nas if the combined 32-bit immediate was added at the location of the\nAUIPC instruction.\n\nSo for matching R_MIPS_PCHI16 and R_MIPS_PCLO16 relocations into pairs\nGAS needs to check for the distance between the two relocations to be\nequal to the difference between the addends supplied, and then the\nlinker has to subtract the low part of the distance between the two\nrelocations from the low part in calculating the high part, so as to\nfactor in any borrow.\n\nA further complication is that `_bfd_mips_elf_lo16_reloc\u0027 handler is\nsupplied with the addend differently depending on whether it has been\ncalled by GAS via `bfd_install_relocation\u0027, or by the generic linker via\n`bfd_perform_relocation\u0027.  In the former case the addend is supplied\nwith the relocation itself while in the latter one it comes from the\nfield being relocated.\n\nWe currently ignore the addend supplied with the relocation and it works\nfor calculating absolute high-part relocations, because the same addend\nhas been previously supplied with them when `_bfd_mips_elf_hi16_reloc\u0027\nwas called, however this approach does not work for the PC-relative case\nbecause as noted above the low-part addend is different and we need to\nconsistently apply the distance adjustment both with GAS and LD.\n\nSince the supplied addend and one retrieved from field being relocated\nwon\u0027t ever be both nonzero, just use the sum of the two values.\n\nThe low-part addend in `mips_elf_add_lo16_rel_addend\u0027 always comes from\nthe field being relocated, so there\u0027s no complication there, we just\nneed to apply the same adjustment.\n\nNew linker test cases verify that the same ultimate machine code is\nproduced both for ELF and S-record output formats, ensuring that the\nboth the MIPS/ELF linker and the generic linker behave in the correct\nway, consistent with each other.\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "6fe93a893e8dee28672eabe1ef8fd4a3dc1b8cbd",
      "old_mode": 33188,
      "old_path": "bfd/elf32-mips.c",
      "new_id": "45856b14af0fd3c3e067c389064b41fe4d2e3e01",
      "new_mode": 33188,
      "new_path": "bfd/elf32-mips.c"
    },
    {
      "type": "modify",
      "old_id": "5b5521079e1b51d0b0f3a90bc706f4596e8f1f63",
      "old_mode": 33188,
      "old_path": "bfd/elf64-mips.c",
      "new_id": "29dcadd3230bc42a25d0b6ab6b16067273afef0a",
      "new_mode": 33188,
      "new_path": "bfd/elf64-mips.c"
    },
    {
      "type": "modify",
      "old_id": "e457bfc984913dcdcb43f8affef54f63bb01b42d",
      "old_mode": 33188,
      "old_path": "bfd/elfn32-mips.c",
      "new_id": "d72e2f5236a025462e632c4da63f5f85603519a1",
      "new_mode": 33188,
      "new_path": "bfd/elfn32-mips.c"
    },
    {
      "type": "modify",
      "old_id": "6f323289ad613948d8208909ebabe1342b398ea5",
      "old_mode": 33188,
      "old_path": "bfd/elfxx-mips.c",
      "new_id": "7d1dff1d7212f4eafd69b77869a87f85be05bde9",
      "new_mode": 33188,
      "new_path": "bfd/elfxx-mips.c"
    },
    {
      "type": "modify",
      "old_id": "9134cef96beede4a20cac705ff5e3adde1f727a6",
      "old_mode": 33188,
      "old_path": "gas/config/tc-mips.c",
      "new_id": "7d0d855911540a7585356d0ad0fa8d62804a7408",
      "new_mode": 33188,
      "new_path": "gas/config/tc-mips.c"
    },
    {
      "type": "modify",
      "old_id": "1a766ffc821c2ae7cde9c17ff006ca6344d8bc1b",
      "old_mode": 33188,
      "old_path": "gas/testsuite/gas/mips/mips.exp",
      "new_id": "73ea41d59c60ec1ebab6fe7bb4210e569c653e15",
      "new_mode": 33188,
      "new_path": "gas/testsuite/gas/mips/mips.exp"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "92c697ffb426372878b0680366cfd8ee96ac5211",
      "new_mode": 33188,
      "new_path": "gas/testsuite/gas/mips/pcrel-hilo-64.d"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "296101cbd5c7fc708da72739f35ba4fdd6de013e",
      "new_mode": 33188,
      "new_path": "gas/testsuite/gas/mips/pcrel-hilo-addend.d"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "5ff66c255c453282bd634cc1b593daf632406084",
      "new_mode": 33188,
      "new_path": "gas/testsuite/gas/mips/pcrel-hilo-match.d"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "dfc8a80680b84036fa0c4e86e11e0dd6c558c134",
      "new_mode": 33188,
      "new_path": "gas/testsuite/gas/mips/pcrel-hilo-match.s"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "aed204a5517bccb97eb2f7d0137b12e94e9c40d5",
      "new_mode": 33188,
      "new_path": "gas/testsuite/gas/mips/pcrel-hilo-n32.d"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "a96e4f2375ebc7ccaca227a7634202faa7de5652",
      "new_mode": 33188,
      "new_path": "gas/testsuite/gas/mips/pcrel-hilo.d"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "4a8278f1b24c4c036a025f83f88a4eb6a3609044",
      "new_mode": 33188,
      "new_path": "gas/testsuite/gas/mips/pcrel-hilo.s"
    },
    {
      "type": "modify",
      "old_id": "e95f1e739cdc905b05b4b90c7c18ba4f43faeca5",
      "old_mode": 33188,
      "old_path": "ld/testsuite/ld-mips-elf/mips-elf.exp",
      "new_id": "6fc960dfc10bc1ec163d588b1fdaf1c5ef278daf",
      "new_mode": 33188,
      "new_path": "ld/testsuite/ld-mips-elf/mips-elf.exp"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "e9b09567f4a96d27986dce0b21a110bfc9352a68",
      "new_mode": 33188,
      "new_path": "ld/testsuite/ld-mips-elf/pcrel-hilo-srec.d"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "ae5d0522229e81022d2c86ef31ef1cabab283a29",
      "new_mode": 33188,
      "new_path": "ld/testsuite/ld-mips-elf/pcrel-hilo.d"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "77d361d9317e688b5a1061447c3587cd641dbc70",
      "new_mode": 33188,
      "new_path": "ld/testsuite/ld-mips-elf/pcrel-hilo.ld"
    }
  ]
}
