diff options
author | mengqinggang <mengqinggang@loongson.cn> | 2024-01-24 14:34:26 +0800 |
---|---|---|
committer | liuzhensong <liuzhensong@loongson.cn> | 2024-03-31 14:21:00 +0800 |
commit | daeda14191c1710ce967259a47ef4e0a3fb6eebf (patch) | |
tree | d812149875b5903fde600bb0e71a17f112b81df2 /gas | |
parent | c7a5bea4c62f286df830418de694821c7617cccd (diff) | |
download | gdb-daeda14191c1710ce967259a47ef4e0a3fb6eebf.zip gdb-daeda14191c1710ce967259a47ef4e0a3fb6eebf.tar.gz gdb-daeda14191c1710ce967259a47ef4e0a3fb6eebf.tar.bz2 |
BFD: Fix the bug of R_LARCH_AGLIN caused by discard section
To represent the first and third expression of .align, R_LARCH_ALIGN need to
associate with a symbol. We define a local symbol for R_LARCH_AGLIN.
But if the section of the local symbol is discarded, it may result in
a undefined symbol error.
Instead, we use the section name symbols, and this does not need to
add extra symbols.
During partial linking (ld -r), if the symbol associated with a relocation is
STT_SECTION type, the addend of relocation needs to add the section output
offset. We prevent it for R_LARCH_ALIGN.
The elf_backend_data.rela_normal only can set all relocations of a target to
rela_normal. Add a new function is_rela_normal to elf_backend_data, it can
set part of relocations to rela_normal.
Diffstat (limited to 'gas')
-rw-r--r-- | gas/config/tc-loongarch.c | 5 | ||||
-rw-r--r-- | gas/testsuite/gas/loongarch/relax_align.d | 6 |
2 files changed, 4 insertions, 7 deletions
diff --git a/gas/config/tc-loongarch.c b/gas/config/tc-loongarch.c index 30aefce..6b1a897 100644 --- a/gas/config/tc-loongarch.c +++ b/gas/config/tc-loongarch.c @@ -1791,10 +1791,7 @@ loongarch_frag_align_code (int n, int max) if (fragP->fr_subtype != 0 && offset > fragP->fr_subtype). */ if (max > 0 && (bfd_vma) max < worst_case_bytes) { - s = symbol_find (".Lla-relax-align"); - if (s == NULL) - s = (symbolS *)local_symbol_make (".Lla-relax-align", now_seg, - &zero_address_frag, 0); + s = symbol_find (now_seg->name); ex.X_add_symbol = s; ex.X_op = O_symbol; ex.X_add_number = (max << 8) | n; diff --git a/gas/testsuite/gas/loongarch/relax_align.d b/gas/testsuite/gas/loongarch/relax_align.d index fc1fd03..acd215a 100644 --- a/gas/testsuite/gas/loongarch/relax_align.d +++ b/gas/testsuite/gas/loongarch/relax_align.d @@ -7,7 +7,7 @@ Disassembly of section .text: -[ ]*0000000000000000 <.Lla-relax-align>: +[ ]*0000000000000000 <.text>: [ ]+0:[ ]+4c000020[ ]+ret [ ]+4:[ ]+03400000[ ]+nop [ ]+4: R_LARCH_ALIGN[ ]+\*ABS\*\+0xc @@ -20,12 +20,12 @@ Disassembly of section .text: [ ]+1c:[ ]+03400000[ ]+nop [ ]+20:[ ]+4c000020[ ]+ret [ ]+24:[ ]+03400000[ ]+nop -[ ]+24: R_LARCH_ALIGN[ ]+.Lla-relax-align\+0x104 +[ ]+24: R_LARCH_ALIGN[ ]+.text\+0x104 [ ]+28:[ ]+03400000[ ]+nop [ ]+2c:[ ]+03400000[ ]+nop [ ]+30:[ ]+4c000020[ ]+ret [ ]+34:[ ]+03400000[ ]+nop -[ ]+34: R_LARCH_ALIGN[ ]+.Lla-relax-align\+0xb04 +[ ]+34: R_LARCH_ALIGN[ ]+.text\+0xb04 [ ]+38:[ ]+03400000[ ]+nop [ ]+3c:[ ]+03400000[ ]+nop [ ]+40:[ ]+4c000020[ ]+ret |