[PATCH v2 7/7] Fix the calculation of the function length
Evgeny Karpov
Evgeny.Karpov@microsoft.com
Fri May 9 11:13:58 GMT 2025
The patch fixes an issue when alignment is applied in the middle of
executed code, affecting the calculation of the function length.
It can be resolved by using the MAP_DATA state.
gas/ChangeLog:
* config/tc-aarch64.h (HANDLE_ALIGN): Update.
---
gas/config/tc-aarch64.h | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/gas/config/tc-aarch64.h b/gas/config/tc-aarch64.h
index 3cd7be5ba34..32e3aafc545 100644
--- a/gas/config/tc-aarch64.h
+++ b/gas/config/tc-aarch64.h
@@ -184,10 +184,16 @@ struct aarch64_frag_type
#define TC_FRAG_INIT(fragp, max_bytes) aarch64_init_frag (fragp, max_bytes)
#define HANDLE_ALIGN(sec, fragp) aarch64_handle_align (fragp)
+/* Sections are assumed to start aligned. In executable section, there is no
+ MAP_DATA symbol pending. So we only align the address during
+ MAP_DATA --> MAP_INSN transition.
+ For other sections, this is not guaranteed. */
#define md_do_align(N, FILL, LEN, MAX, LABEL) \
if (FILL == NULL && (N) != 0 && ! need_pass_2 && subseg_text_p (now_seg)) \
{ \
- frag_align_code (N, MAX); \
+ enum mstate mapstate = seg_info (now_seg)->tc_segment_info_data.mapstate; \
+ if (mapstate == MAP_DATA) \
+ frag_align_code (N, MAX); \
goto LABEL; \
}
--
2.25.1
More information about the Binutils
mailing list