* [RFC PATCH] bfd: use bfd_vma for the 64-bit version of put[lb] and get[lb]
@ 2022-10-04 20:03 Frédéric Pétrot
2022-10-05 2:59 ` Alan Modra
0 siblings, 1 reply; 2+ messages in thread
From: Frédéric Pétrot @ 2022-10-04 20:03 UTC (permalink / raw)
To: binutils
Hi,
During summer (around Aug.4) Alan replaced in many places the use
of bfd_vma and such by the c99 types.
However, when compiling for an ad-hoc target of ours, the fact
that the 64-bit version of the put and get functions does not
share the same prototypes as the other bit-width versions needs a
patch while making the prototypes consistent might be acceptable,
what do you think?
Thanks,
Frédéric
The 16-bit, 24-bit and 32-bit versions of these functions use an
argument of type bfd_[signed_]vma while the 64-bit version uses
[u]int64_t. Given the comment in front of the definition of the
bfd vma types in bfd-in.h, the use of the bfd specific types
should be possible and would make the code consistent across all
function versions.
bfd/
* bfd-in.h: change argument or return value types in put/get
functions prototypes
* libbfd.c: likewise for implementations
---
bfd/bfd-in.h | 12 ++++++------
bfd/libbfd.c | 12 ++++++------
2 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h
index 4765ea80536..9efb5ce5a84 100644
--- a/bfd/bfd-in.h
+++ b/bfd/bfd-in.h
@@ -403,10 +403,10 @@ extern bool bfd_record_phdr
/* Byte swapping routines. */
-uint64_t bfd_getb64 (const void *);
-uint64_t bfd_getl64 (const void *);
-int64_t bfd_getb_signed_64 (const void *);
-int64_t bfd_getl_signed_64 (const void *);
+bfd_vma bfd_getb64 (const void *);
+bfd_vma bfd_getl64 (const void *);
+bfd_signed_vma bfd_getb_signed_64 (const void *);
+bfd_signed_vma bfd_getl_signed_64 (const void *);
bfd_vma bfd_getb32 (const void *);
bfd_vma bfd_getl32 (const void *);
bfd_signed_vma bfd_getb_signed_32 (const void *);
@@ -415,8 +415,8 @@ bfd_vma bfd_getb16 (const void *);
bfd_vma bfd_getl16 (const void *);
bfd_signed_vma bfd_getb_signed_16 (const void *);
bfd_signed_vma bfd_getl_signed_16 (const void *);
-void bfd_putb64 (uint64_t, void *);
-void bfd_putl64 (uint64_t, void *);
+void bfd_putb64 (bfd_vma, void *);
+void bfd_putl64 (bfd_vma, void *);
void bfd_putb32 (bfd_vma, void *);
void bfd_putl32 (bfd_vma, void *);
void bfd_putb24 (bfd_vma, void *);
diff --git a/bfd/libbfd.c b/bfd/libbfd.c
index d33f3416206..5eab59d2e76 100644
--- a/bfd/libbfd.c
+++ b/bfd/libbfd.c
@@ -757,7 +757,7 @@ bfd_getl_signed_32 (const void *p)
return COERCE32 (v);
}
-uint64_t
+bfd_vma
bfd_getb64 (const void *p)
{
const bfd_byte *addr = (const bfd_byte *) p;
@@ -775,7 +775,7 @@ bfd_getb64 (const void *p)
return v;
}
-uint64_t
+bfd_vma
bfd_getl64 (const void *p)
{
const bfd_byte *addr = (const bfd_byte *) p;
@@ -793,7 +793,7 @@ bfd_getl64 (const void *p)
return v;
}
-int64_t
+bfd_signed_vma
bfd_getb_signed_64 (const void *p)
{
const bfd_byte *addr = (const bfd_byte *) p;
@@ -811,7 +811,7 @@ bfd_getb_signed_64 (const void *p)
return COERCE64 (v);
}
-int64_t
+bfd_signed_vma
bfd_getl_signed_64 (const void *p)
{
const bfd_byte *addr = (const bfd_byte *) p;
@@ -850,7 +850,7 @@ bfd_putl32 (bfd_vma data, void *p)
}
void
-bfd_putb64 (uint64_t data, void *p)
+bfd_putb64 (bfd_vma data, void *p)
{
bfd_byte *addr = (bfd_byte *) p;
addr[0] = (data >> (7*8)) & 0xff;
@@ -864,7 +864,7 @@ bfd_putb64 (uint64_t data, void *p)
}
void
-bfd_putl64 (uint64_t data, void *p)
+bfd_putl64 (bfd_vma data, void *p)
{
bfd_byte *addr = (bfd_byte *) p;
addr[7] = (data >> (7*8)) & 0xff;
--
2.30.2
--
+---------------------------------------------------------------------------+
| Frédéric Pétrot, Pr. Grenoble INP-Ensimag/TIMA |
| Mob/Pho: +33 6 74 57 99 65/+33 4 76 57 48 70 Ad augusta per angusta |
| http://tima.univ-grenoble-alpes.fr frederic.petrot@univ-grenoble-alpes.fr |
+---------------------------------------------------------------------------+
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [RFC PATCH] bfd: use bfd_vma for the 64-bit version of put[lb] and get[lb]
2022-10-04 20:03 [RFC PATCH] bfd: use bfd_vma for the 64-bit version of put[lb] and get[lb] Frédéric Pétrot
@ 2022-10-05 2:59 ` Alan Modra
0 siblings, 0 replies; 2+ messages in thread
From: Alan Modra @ 2022-10-05 2:59 UTC (permalink / raw)
To: Frédéric Pétrot; +Cc: binutils
> -uint64_t bfd_getb64 (const void *);
> -uint64_t bfd_getl64 (const void *);
> -int64_t bfd_getb_signed_64 (const void *);
> -int64_t bfd_getl_signed_64 (const void *);
> +bfd_vma bfd_getb64 (const void *);
> +bfd_vma bfd_getl64 (const void *);
> +bfd_signed_vma bfd_getb_signed_64 (const void *);
> +bfd_signed_vma bfd_getl_signed_64 (const void *);
No, you can't use bfd_vma here. Configuring on a 32-bit host without
--enable-64-bit-bfd or selecting a 64-bit target will result in
bfd_vma being a 32-bit type.
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-10-05 2:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-04 20:03 [RFC PATCH] bfd: use bfd_vma for the 64-bit version of put[lb] and get[lb] Frédéric Pétrot
2022-10-05 2:59 ` Alan Modra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).