There were two issues that broke branch instructions and relocations in the linked binary:
The symbol table entry for the nonmatching function name was not updated after injection. Instead, it pointed to the first function in the file. As a result, calls to the nonmatching function actually called the first file function. This fix updates the symbol table entry to point to the correct .text section in the final object file.
Most .rela.text sections were omitted from the final object file. The original algorithm did not inject relocations into any parts of a .text section that were overridden. This produces a bug for mwcc objects because the implementation assumed that object files would only contain a single .text section (mwcc produces multiple). This check has been disabled.
With this change, GLOBAL_ASM can be used on nonmatching functions and produce a matching binary.
There were two issues that broke branch instructions and relocations in the linked binary:
.text
section in the final object file..rela.text
sections were omitted from the final object file. The original algorithm did not inject relocations into any parts of a.text
section that were overridden. This produces a bug for mwcc objects because the implementation assumed that object files would only contain a single.text
section (mwcc produces multiple). This check has been disabled.With this change,
GLOBAL_ASM
can be used on nonmatching functions and produce a matching binary.