diff options
author | Indu Bhagat <indu.bhagat@oracle.com> | 2023-01-06 09:30:20 -0800 |
---|---|---|
committer | Indu Bhagat <indu.bhagat@oracle.com> | 2023-01-06 09:30:56 -0800 |
commit | 725a19bfd142c845bf76ae28f6289972fd1cf5db (patch) | |
tree | d4312aa9fa29f28f4b2be090e87f0def39972629 /libsframe | |
parent | libsframe: adjust an incorrect check in flip_sframe (diff) | |
download | binutils-gdb-725a19bfd142c845bf76ae28f6289972fd1cf5db.tar.gz binutils-gdb-725a19bfd142c845bf76ae28f6289972fd1cf5db.tar.bz2 binutils-gdb-725a19bfd142c845bf76ae28f6289972fd1cf5db.zip |
sframe: fix the defined SFRAME_FRE_TYPE_*_LIMIT constants
An earlier commit 3f107464 defined the SFRAME_FRE_TYPE_*_LIMIT
constants. These constants are used (by gas and libsframe) to pick an
SFrame FRE type based on the function size. Those constants, however,
were buggy, causing the generated SFrame sections to be bloated as
SFRAME_FRE_TYPE_ADDR2/SFRAME_FRE_TYPE_ADDR4 got chosen more often than
necessary.
gas/
* sframe-opt.c (sframe_estimate_size_before_relax): Use
typecast.
(sframe_convert_frag): Likewise.
libsframe/
* sframe.c (sframe_calc_fre_type): Use a more appropriate type
for argument. Adjust the check for SFRAME_FRE_TYPE_ADDR4_LIMIT
to keep it warning-free but meaningful.
include/
* sframe-api.h (sframe_calc_fre_type): Use a more appropriate
type for the argument.
* sframe.h (SFRAME_FRE_TYPE_ADDR1_LIMIT): Correct the constant.
(SFRAME_FRE_TYPE_ADDR2_LIMIT): Likewise.
(SFRAME_FRE_TYPE_ADDR4_LIMIT): Likewise.
Diffstat (limited to 'libsframe')
-rw-r--r-- | libsframe/sframe.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/libsframe/sframe.c b/libsframe/sframe.c index d206780289a..ea3169ba7aa 100644 --- a/libsframe/sframe.c +++ b/libsframe/sframe.c @@ -584,14 +584,16 @@ sframe_fde_create_func_info (unsigned int fre_type, /* FIXME API for linker. Revisit if its better placed somewhere else? */ unsigned int -sframe_calc_fre_type (unsigned int func_size) +sframe_calc_fre_type (size_t func_size) { unsigned int fre_type = 0; if (func_size < SFRAME_FRE_TYPE_ADDR1_LIMIT) fre_type = SFRAME_FRE_TYPE_ADDR1; else if (func_size < SFRAME_FRE_TYPE_ADDR2_LIMIT) fre_type = SFRAME_FRE_TYPE_ADDR2; - else if (func_size < SFRAME_FRE_TYPE_ADDR4_LIMIT) + /* Adjust the check a bit so that it remains warning-free but meaningful + on 32-bit systems. */ + else if (func_size <= (size_t) (SFRAME_FRE_TYPE_ADDR4_LIMIT - 1)) fre_type = SFRAME_FRE_TYPE_ADDR4; return fre_type; } |