)]}'
{
  "commit": "da208daeb710b26608a0b981df215e9da209af80",
  "tree": "7131e9c775a1bdf89c3d84471f1575e05d02b668",
  "parents": [
    "34fc62a27e1d8827aa2e64610f4e4b03e5825fc3"
  ],
  "author": {
    "name": "H.J. Lu",
    "email": "hjl.tools@gmail.com",
    "time": "Wed Apr 22 03:53:20 2026 +0800"
  },
  "committer": {
    "name": "H.J. Lu",
    "email": "hjl.tools@gmail.com",
    "time": "Thu Apr 23 06:02:13 2026 +0800"
  },
  "message": "ld: Maintain the input file order\n\nWhen adding a new input archive, which comes from a linker script file\nand isn\u0027t referenced by any inputs, ld appends it to the input file list.\nOn Linux, when -lm is used with /usr/lib64/libm.a:\n\nGROUP ( /usr/lib64/libm-2.42.a /usr/lib64/libmvec.a )\n\nthe input file order looks like\n\n/usr/lib/gcc/x86_64-redhat-linux/15/../../../../lib64/crt1.o\n/usr/lib/gcc/x86_64-redhat-linux/15/../../../../lib64/crti.o\n/usr/lib/gcc/x86_64-redhat-linux/15/crtbeginT.o\nx.o (symbol from plugin)\n/usr/lib/gcc/x86_64-redhat-linux/15/../../../../lib64/libm.a\n/usr/lib/gcc/x86_64-redhat-linux/15/libgcc.a\n/usr/lib/gcc/x86_64-redhat-linux/15/libgcc_eh.a\n/usr/lib/gcc/x86_64-redhat-linux/15/../../../../lib64/libc.a\n/usr/lib/gcc/x86_64-redhat-linux/15/crtend.o\n/usr/lib/gcc/x86_64-redhat-linux/15/../../../../lib64/crtn.o\n/usr/lib64/libm-2.42.a\n/usr/lib64/libmvec.a\n\nsince the compiler may not add compiler builtin functions to the LTO\nsymbol table as it doesn\u0027t really know if builtin functions will have\nreal symbols.  When ld extracts an element from the archive later during\nLTO rescan, the final input file order is\n\n/usr/lib/gcc/x86_64-redhat-linux/15/../../../../lib64/crt1.o\n/usr/lib/gcc/x86_64-redhat-linux/15/../../../../lib64/crti.o\n/usr/lib/gcc/x86_64-redhat-linux/15/crtbeginT.o\nx.o (symbol from plugin)\n/tmp/ccHN6O4n.ltrans0.ltrans.o\n/usr/lib/gcc/x86_64-redhat-linux/15/../../../../lib64/libm.a\n/usr/lib/gcc/x86_64-redhat-linux/15/libgcc.a\n/usr/lib/gcc/x86_64-redhat-linux/15/libgcc_eh.a\n/usr/lib/gcc/x86_64-redhat-linux/15/../../../../lib64/libc.a\n/usr/lib/gcc/x86_64-redhat-linux/15/crtend.o\n/usr/lib/gcc/x86_64-redhat-linux/15/../../../../lib64/crtn.o\nfclrexcpt.o\n\nwhere x.o references the builtin function, feclearexcept which is defined\nin fclrexcpt.o from /usr/lib64/libm-2.42.a.\n\nAs the result, the .eh_frame section terminator in crtn.o is placed before\nfclrexcpt.o and the .eh_frame section in the output isn\u0027t terminated.  The\noutput crashes when it runs over the .eh_frame section during EH frame\nregistration.  Insert the new input file before the current input file to\nmaintain the same input file order:\n\n/usr/lib/gcc/x86_64-redhat-linux/15/../../../../lib64/crt1.o\n/usr/lib/gcc/x86_64-redhat-linux/15/../../../../lib64/crti.o\n/usr/lib/gcc/x86_64-redhat-linux/15/crtbeginT.o\nx.o (symbol from plugin)\n/usr/lib64/libm-2.42.a\n/usr/lib64/libmvec.a\n/usr/lib/gcc/x86_64-redhat-linux/15/../../../../lib64/libm.a\n/usr/lib/gcc/x86_64-redhat-linux/15/libgcc.a\n/usr/lib/gcc/x86_64-redhat-linux/15/libgcc_eh.a\n/usr/lib/gcc/x86_64-redhat-linux/15/../../../../lib64/libc.a\n/usr/lib/gcc/x86_64-redhat-linux/15/crtend.o\n/usr/lib/gcc/x86_64-redhat-linux/15/../../../../lib64/crtn.o\n\nas the non-LTO input to properly terminate the .eh_frame section.\n\nAdd a static LTO test to reference feclearexcept which is a compiler\nbuiltin function and isn\u0027t in the LTO symbol table when GCC is used.\nIt triggers the run-time crash on glibc targets of a linker script\nlibm.a without this fix when GCC 13 or above is used:\n\nhttps://gcc.gnu.org/bugzilla/show_bug.cgi?id\u003d124869\n\nAlso add a debug function, debug_input_files, to display the input file\nchain.  It is optimized out when compiler optimization is turned on.\n\n\tPR ld/34088\n\t* ldlang.c (current_input_file): Changed to the pointer to\n\tlang_input_statement_type.\n\t(new_afile): Insert the new input file before the current input\n\tfile to maintain the input file order.\n\t(lang_add_input_file): Updated.\n\t(load_symbols): Likewise.\n\t(debug_input_files): New function.\n\t(lang_process): Reference it.\n\t* testsuite/ld-plugin/lto.exp: Run PR ld/34088 test.\n\t* testsuite/ld-plugin/pr34088.c: New file.\n\nSigned-off-by: H.J. Lu \u003chjl.tools@gmail.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "98adc90e58a2e1ef8d78986ddb749db43e2ef6e4",
      "old_mode": 33188,
      "old_path": "ld/ldlang.c",
      "new_id": "d75f9df4d434f03ecbc28f6b4633e457fad6bd98",
      "new_mode": 33188,
      "new_path": "ld/ldlang.c"
    },
    {
      "type": "modify",
      "old_id": "139bc0b9f98329b1b0e4d5cec92965c81b521589",
      "old_mode": 33188,
      "old_path": "ld/testsuite/ld-plugin/lto.exp",
      "new_id": "62cca45f42b915f1c53480ba92ad8026f69866db",
      "new_mode": 33188,
      "new_path": "ld/testsuite/ld-plugin/lto.exp"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "dfa2ca6903bba007d4d861a2a1cb878efdf0d80a",
      "new_mode": 33188,
      "new_path": "ld/testsuite/ld-plugin/pr34088.c"
    }
  ]
}
