public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] bfd: Use size_t in the BFD mmap interface
@ 2024-03-13 13:54 H.J. Lu
  2024-03-15 16:20 ` Tom Tromey
  0 siblings, 1 reply; 2+ messages in thread
From: H.J. Lu @ 2024-03-13 13:54 UTC (permalink / raw)
  To: binutils

This is the part of elf: Use mmap to map in read-only sections:

https://sourceware.org/pipermail/binutils/2024-March/132868.html

and was approved in:

https://sourceware.org/pipermail/binutils/2024-March/132880.html

I am checking in this part.

H.J.
----
Change the size type in the BFD mmap interface from bfd_size_type to
size_t to be consistent with the size type of the host mmap interface.

	* bfdio.c (bfd_iovec): Change the bmmap size type to size_t.
	(bfd_mmap): Likewise.
	(memory_bmmap): Likewise.
	* cache.c (cache_bmmap): Change the bmmap size type to size_t.
	* opncls.c (opncls_bmmap): Change the bmmap size type to size_t.
	* bfd-in2.h: Regenerated.
	* libbfd.h: Likewise.
---
 bfd/bfd-in2.h |  4 ++--
 bfd/bfdio.c   | 16 ++++++++--------
 bfd/cache.c   |  4 ++--
 bfd/libbfd.h  |  4 ++--
 bfd/opncls.c  |  4 ++--
 5 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 79b24a7f6e9..29602e054da 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -2768,9 +2768,9 @@ ufile_ptr bfd_get_size (bfd *abfd);
 
 ufile_ptr bfd_get_file_size (bfd *abfd);
 
-void *bfd_mmap (bfd *abfd, void *addr, bfd_size_type len,
+void *bfd_mmap (bfd *abfd, void *addr, size_t len,
     int prot, int flags, file_ptr offset,
-    void **map_addr, bfd_size_type *map_len)
+    void **map_addr, size_t *map_len)
 ATTRIBUTE_WARN_UNUSED_RESULT;
 
 time_t bfd_get_current_time (time_t now);
diff --git a/bfd/bfdio.c b/bfd/bfdio.c
index 1572de00ad4..4ed0eeadc52 100644
--- a/bfd/bfdio.c
+++ b/bfd/bfdio.c
@@ -219,9 +219,9 @@ DESCRIPTION
 .     Also write in MAP_ADDR the address of the page aligned buffer and in
 .     MAP_LEN the size mapped (a page multiple).  Use unmap with MAP_ADDR and
 .     MAP_LEN to unmap.  *}
-.  void *(*bmmap) (struct bfd *abfd, void *addr, bfd_size_type len,
+.  void *(*bmmap) (struct bfd *abfd, void *addr, size_t len,
 .		   int prot, int flags, file_ptr offset,
-.		   void **map_addr, bfd_size_type *map_len);
+.		   void **map_addr, size_t *map_len);
 .};
 
 .extern const struct bfd_iovec _bfd_memory_iovec;
@@ -638,9 +638,9 @@ FUNCTION
 	bfd_mmap
 
 SYNOPSIS
-	void *bfd_mmap (bfd *abfd, void *addr, bfd_size_type len,
+	void *bfd_mmap (bfd *abfd, void *addr, size_t len,
 			int prot, int flags, file_ptr offset,
-			void **map_addr, bfd_size_type *map_len)
+			void **map_addr, size_t *map_len)
 			ATTRIBUTE_WARN_UNUSED_RESULT;
 
 DESCRIPTION
@@ -651,9 +651,9 @@ DESCRIPTION
 */
 
 void *
-bfd_mmap (bfd *abfd, void *addr, bfd_size_type len,
+bfd_mmap (bfd *abfd, void *addr, size_t len,
 	  int prot, int flags, file_ptr offset,
-	  void **map_addr, bfd_size_type *map_len)
+	  void **map_addr, size_t *map_len)
 {
   while (abfd->my_archive != NULL
 	 && !bfd_is_thin_archive (abfd->my_archive))
@@ -815,10 +815,10 @@ memory_bstat (bfd *abfd, struct stat *statbuf)
 
 static void *
 memory_bmmap (bfd *abfd ATTRIBUTE_UNUSED, void *addr ATTRIBUTE_UNUSED,
-	      bfd_size_type len ATTRIBUTE_UNUSED, int prot ATTRIBUTE_UNUSED,
+	      size_t len ATTRIBUTE_UNUSED, int prot ATTRIBUTE_UNUSED,
 	      int flags ATTRIBUTE_UNUSED, file_ptr offset ATTRIBUTE_UNUSED,
 	      void **map_addr ATTRIBUTE_UNUSED,
-	      bfd_size_type *map_len ATTRIBUTE_UNUSED)
+	      size_t *map_len ATTRIBUTE_UNUSED)
 {
   return (void *)-1;
 }
diff --git a/bfd/cache.c b/bfd/cache.c
index 3bc2afc9f36..d0e7be293a5 100644
--- a/bfd/cache.c
+++ b/bfd/cache.c
@@ -478,12 +478,12 @@ cache_bstat (struct bfd *abfd, struct stat *sb)
 static void *
 cache_bmmap (struct bfd *abfd ATTRIBUTE_UNUSED,
 	     void *addr ATTRIBUTE_UNUSED,
-	     bfd_size_type len ATTRIBUTE_UNUSED,
+	     size_t len ATTRIBUTE_UNUSED,
 	     int prot ATTRIBUTE_UNUSED,
 	     int flags ATTRIBUTE_UNUSED,
 	     file_ptr offset ATTRIBUTE_UNUSED,
 	     void **map_addr ATTRIBUTE_UNUSED,
-	     bfd_size_type *map_len ATTRIBUTE_UNUSED)
+	     size_t *map_len ATTRIBUTE_UNUSED)
 {
   void *ret = MAP_FAILED;
 
diff --git a/bfd/libbfd.h b/bfd/libbfd.h
index a60063b5ae1..f15b5f27db8 100644
--- a/bfd/libbfd.h
+++ b/bfd/libbfd.h
@@ -969,9 +969,9 @@ struct bfd_iovec
      Also write in MAP_ADDR the address of the page aligned buffer and in
      MAP_LEN the size mapped (a page multiple).  Use unmap with MAP_ADDR and
      MAP_LEN to unmap.  */
-  void *(*bmmap) (struct bfd *abfd, void *addr, bfd_size_type len,
+  void *(*bmmap) (struct bfd *abfd, void *addr, size_t len,
 		  int prot, int flags, file_ptr offset,
-		  void **map_addr, bfd_size_type *map_len);
+		  void **map_addr, size_t *map_len);
 };
 extern const struct bfd_iovec _bfd_memory_iovec;
 
diff --git a/bfd/opncls.c b/bfd/opncls.c
index 096672475c4..c764d204831 100644
--- a/bfd/opncls.c
+++ b/bfd/opncls.c
@@ -668,12 +668,12 @@ opncls_bstat (struct bfd *abfd, struct stat *sb)
 static void *
 opncls_bmmap (struct bfd *abfd ATTRIBUTE_UNUSED,
 	      void *addr ATTRIBUTE_UNUSED,
-	      bfd_size_type len ATTRIBUTE_UNUSED,
+	      size_t len ATTRIBUTE_UNUSED,
 	      int prot ATTRIBUTE_UNUSED,
 	      int flags ATTRIBUTE_UNUSED,
 	      file_ptr offset ATTRIBUTE_UNUSED,
 	      void **map_addr ATTRIBUTE_UNUSED,
-	      bfd_size_type *map_len ATTRIBUTE_UNUSED)
+	      size_t *map_len ATTRIBUTE_UNUSED)
 {
   return MAP_FAILED;
 }
-- 
2.44.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] bfd: Use size_t in the BFD mmap interface
  2024-03-13 13:54 [PATCH] bfd: Use size_t in the BFD mmap interface H.J. Lu
@ 2024-03-15 16:20 ` Tom Tromey
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2024-03-15 16:20 UTC (permalink / raw)
  To: H.J. Lu; +Cc: binutils

>>>>> "HJ" == H J Lu <hjl.tools@gmail.com> writes:

HJ> This is the part of elf: Use mmap to map in read-only sections:
HJ> https://sourceware.org/pipermail/binutils/2024-March/132868.html

HJ> and was approved in:

HJ> https://sourceware.org/pipermail/binutils/2024-March/132880.html

HJ> I am checking in this part.

If bfd_size_type ever differs from size_t then this patch would cause a
gdb build failure.

I'll patch gdb here shortly.

Tom

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-03-15 16:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-13 13:54 [PATCH] bfd: Use size_t in the BFD mmap interface H.J. Lu
2024-03-15 16:20 ` Tom Tromey

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).