@@ -2078,63 +2078,36 @@ s_bss (int ignore ATTRIBUTE_UNUSED)
2078
2078
demand_empty_rest_of_line ();
2079
2079
}
2080
2080
2081
- /* Align to a given power of two. */
2081
+ /* Called from md_do_align. Used to create an alignment frag in a
2082
+ code section by emitting a worst-case NOP sequence that the linker
2083
+ will later relax to the correct number of NOPs. We can't compute
2084
+ the correct alignment now because of other linker relaxations. */
2082
2085
2083
- static void
2084
- s_align (int bytes_p )
2086
+ void
2087
+ riscv_frag_align_code (int n , int max )
2085
2088
{
2086
- int fill_value = 0 , fill_value_specified = 0 ;
2087
- int min_text_alignment = riscv_opts .rvc ? 2 : 4 ;
2088
- int alignment = get_absolute_expression (), bytes ;
2089
+ bfd_vma bytes = (bfd_vma )1 << n ;
2090
+ bfd_vma min_text_alignment = riscv_opts .rvc ? 2 : 4 ;
2089
2091
2090
- if (bytes_p )
2092
+ if (bytes > min_text_alignment )
2091
2093
{
2092
- bytes = alignment ;
2093
- if (bytes < 1 || (bytes & (bytes - 1 )) != 0 )
2094
- as_bad (_ ("alignment not a power of 2: %d" ), bytes );
2095
- for (alignment = 0 ; bytes > 1 ; bytes >>= 1 )
2096
- alignment ++ ;
2097
- }
2098
-
2099
- bytes = 1 << alignment ;
2100
-
2101
- if (alignment < 0 || alignment > 31 )
2102
- as_bad (_ ("unsatisfiable alignment: %d" ), alignment );
2103
-
2104
- if (* input_line_pointer == ',' )
2105
- {
2106
- ++ input_line_pointer ;
2107
- fill_value = get_absolute_expression ();
2108
- fill_value_specified = 1 ;
2109
- }
2110
-
2111
- if (!fill_value_specified
2112
- && subseg_text_p (now_seg )
2113
- && bytes > min_text_alignment )
2114
- {
2115
- /* Emit the worst-case NOP string. The linker will delete any
2116
- unnecessary NOPs. This allows us to support code alignment
2117
- in spite of linker relaxations. */
2118
- bfd_vma i , worst_case_bytes = bytes - min_text_alignment ;
2094
+ bfd_vma worst_case_bytes = bytes - min_text_alignment ;
2119
2095
char * nops = frag_more (worst_case_bytes );
2096
+ expressionS ex ;
2097
+ bfd_vma i ;
2098
+
2120
2099
for (i = 0 ; i < worst_case_bytes - 2 ; i += 4 )
2121
2100
md_number_to_chars (nops + i , RISCV_NOP , 4 );
2101
+
2122
2102
if (i < worst_case_bytes )
2123
2103
md_number_to_chars (nops + i , RVC_NOP , 2 );
2124
2104
2125
- expressionS ex ;
2126
2105
ex .X_op = O_constant ;
2127
2106
ex .X_add_number = worst_case_bytes ;
2128
2107
2129
2108
fix_new_exp (frag_now , nops - frag_now -> fr_literal , 0 ,
2130
2109
& ex , FALSE, BFD_RELOC_RISCV_ALIGN );
2131
2110
}
2132
- else if (alignment )
2133
- frag_align (alignment , fill_value , 0 );
2134
-
2135
- record_alignment (now_seg , alignment );
2136
-
2137
- demand_empty_rest_of_line ();
2138
2111
}
2139
2112
2140
2113
int
@@ -2381,9 +2354,6 @@ static const pseudo_typeS riscv_pseudo_table[] =
2381
2354
{"dtprelword" , s_dtprel , 4 },
2382
2355
{"dtpreldword" , s_dtprel , 8 },
2383
2356
{"bss" , s_bss , 0 },
2384
- {"align" , s_align , 0 },
2385
- {"p2align" , s_align , 0 },
2386
- {"balign" , s_align , 1 },
2387
2357
{"uleb128" , s_riscv_leb128 , 0 },
2388
2358
{"sleb128" , s_riscv_leb128 , 1 },
2389
2359
0 commit comments