LoongArch: Emit relocations for .long 0x2eef - symbol
LoongArch assembler now correctly emits relocations for expressions involving subtraction with a symbol.
The LoongArch assembler has been updated to correctly emit relocations for expressions like .long 0x2eef - symbol. Previously, the assembler could not generate these relocations when fx_addsy was NULL in fixup_segment. This change modifies md_apply_fix to set fx_addsy to abs_section_sym, enabling the generation of necessary relocations.
In Details
This commit addresses an issue in gas/config/tc-loongarch.c where expressions of the form constant - symbol used with .long directives failed to generate appropriate relocations. The problem stemmed from fx_addsy being NULL in fixup_segment, preventing md_apply_fix from handling these cases. The fix involves setting fx_addsy to abs_section_sym within md_apply_fix, ensuring that the assembler can correctly generate the required ADD/SUB relocations for LoongArch.
- relocation
- A directive in object code that tells the linker how to modify certain instructions or data before the executable code can be run. This typically involves adjusting addresses or offsets to be correct in the final program image.
- .long
- An assembler directive that instructs the assembler to output a 32-bit integer value. In this context, it's used to embed constants or results of expressions directly into the code or data sections.
- ADD/SUB relocations
- Specific types of relocations used to encode the result of an addition or subtraction at link time. This commit ensures these are generated correctly for expressions involving a symbol.
- symbol
- A name that represents a memory address or a value within a program. Symbols are used by assemblers and linkers to refer to variables, functions, or labels.
- Program Counter (PC)
- A register in the CPU that stores the address of the next instruction to be executed. Instructions or data that refer to addresses relative to the PC are called PC-relative.
- fixup
- A process performed by the assembler or linker to resolve addresses or apply relocations. It corrects placeholder values in instructions or data to their final, correct values.