[PATCH 52/59] fixup! libctf, link: tie in the deduplicating linker

Nick Alcock nick.alcock@oracle.com
Wed Jul 22 09:36:50 GMT 2020


We can't use -1 here without causing trouble on platforms with 32-bit
ssize_t.  We also have to cast the input to labs to long int to allow
for platforms on which ssize_t is long long (it's easier to do that
than it is to use llabs, which is less common: counts of inputs that
exceed 32 bits are prohibited anyway so we don't care about any
precision loss that high up.)

So much work for such an unlikely error case :)
---
 libctf/ctf-link.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libctf/ctf-link.c b/libctf/ctf-link.c
index fd7298749cd..f269fe7ac0e 100644
--- a/libctf/ctf-link.c
+++ b/libctf/ctf-link.c
@@ -1176,14 +1176,15 @@ ctf_link_deduplicating_per_cu (ctf_file_t *fp)
       uint32_t noutputs;
       uint32_t *parents;
 
-      if ((ninputs = ctf_link_deduplicating_count_inputs (fp, in, &only_input)) < 0)
+      if ((ninputs = ctf_link_deduplicating_count_inputs (fp, in,
+							  &only_input)) == -1)
 	goto err_open_inputs;
 
       /* CU mapping with no inputs?  Skip.  */
       if (ninputs == 0)
 	continue;
 
-      if (ninputs > -1)
+      if (labs ((long int) ninputs) > 0xfffffffe)
 	{
 	  ctf_err_warn (fp, 0, "Too many inputs in deduplicating link: %li",
 			(long int) ninputs);
-- 
2.27.0.247.g3dff7de930


More information about the Binutils mailing list