diff options
author | mengqinggang <mengqinggang@loongson.cn> | 2024-02-05 16:16:52 +0800 |
---|---|---|
committer | liuzhensong <liuzhensong@loongson.cn> | 2024-02-23 15:40:34 +0800 |
commit | c429c4459865284a0059cbabdde0449eb7df0774 (patch) | |
tree | 906de2ed770ca3d5ca7a2189dd44127302ac52ff /gas/config/tc-loongarch.c | |
parent | 97f2a34ed1d255ea301f858b31c0fbe75da1c4f6 (diff) | |
download | gdb-c429c4459865284a0059cbabdde0449eb7df0774.zip gdb-c429c4459865284a0059cbabdde0449eb7df0774.tar.gz gdb-c429c4459865284a0059cbabdde0449eb7df0774.tar.bz2 |
LoongArch: gas: Try to avoid R_LARCH_ALIGN associate with a symbol
The R_LARCH_ALIGN need to associated with a symbol if .align has the first
and third expressions. If R_LARCH_ALIGN associate with a symbol, the addend can
represent the first and third expression of .align.
For '.align 3', the addend of R_LARCH_ALIGN only need to represent the alignment
and R_LARCH_ALIGN not need to associate with a symbol.
For '.align x, , y', R_LARCH_ALIGN need to associate with a symbol if 0 < y <
2^x - 4.
Diffstat (limited to 'gas/config/tc-loongarch.c')
-rw-r--r-- | gas/config/tc-loongarch.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/gas/config/tc-loongarch.c b/gas/config/tc-loongarch.c index 91f5f1d..de92366 100644 --- a/gas/config/tc-loongarch.c +++ b/gas/config/tc-loongarch.c @@ -1746,14 +1746,25 @@ loongarch_frag_align_code (int n, int max) nops = frag_more (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); - - ex.X_add_symbol = s; - ex.X_op = O_symbol; - ex.X_add_number = (max << 8) | n; + /* If max <= 0, ignore max. + If max >= worst_case_bytes, max has no effect. + Similar to gas/write.c relax_segment function rs_align_code case: + 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); + ex.X_add_symbol = s; + ex.X_op = O_symbol; + ex.X_add_number = (max << 8) | n; + } + else + { + ex.X_op = O_constant; + ex.X_add_number = worst_case_bytes; + } loongarch_make_nops (nops, worst_case_bytes); |