public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2] bfd: Define pagesize variables only for mmap
@ 2024-04-09  2:39 H.J. Lu
  2024-04-09  5:41 ` Alan Modra
  0 siblings, 1 reply; 2+ messages in thread
From: H.J. Lu @ 2024-04-09  2:39 UTC (permalink / raw)
  To: binutils; +Cc: amodra, simon.marchi

Define _bfd_pagesize, _bfd_pagesize_m1 and _bfd_minimum_mmap_size only
if HAVE_MMAP is defined.

	* libbfd-in.h (_bfd_pagesize): Declare only if HAVE_MMAP is
	defined.
	(_bfd_pagesize_m1): Likewise.
	(_bfd_minimum_mmap_size): Likewise.
	* libbfd.c (_bfd_pagesize): Define only if HAVE_MMAP is defined.
	(_bfd_pagesize_m1): Likewise.
	(_bfd_minimum_mmap_size): Likewise.
	(bfd_init_pagesize): Likewise.
	* lynx-core.c (lynx_core_file_p): Replace _bfd_pagesize with
	getpagesize.
---
 bfd/libbfd-in.h | 2 ++
 bfd/libbfd.c    | 2 ++
 bfd/libbfd.h    | 2 ++
 bfd/lynx-core.c | 2 +-
 4 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h
index 7bfc58f12d8..81898d406ab 100644
--- a/bfd/libbfd-in.h
+++ b/bfd/libbfd-in.h
@@ -848,9 +848,11 @@ extern bfd_byte * _bfd_write_unsigned_leb128
 extern struct bfd_link_info *_bfd_get_link_info (bfd *)
   ATTRIBUTE_HIDDEN;
 
+#ifdef HAVE_MMAP
 extern uintptr_t _bfd_pagesize ATTRIBUTE_HIDDEN;
 extern uintptr_t _bfd_pagesize_m1 ATTRIBUTE_HIDDEN;
 extern uintptr_t _bfd_minimum_mmap_size ATTRIBUTE_HIDDEN;
+#endif
 
 #if GCC_VERSION >= 7000
 #define _bfd_mul_overflow(a, b, res) __builtin_mul_overflow (a, b, res)
diff --git a/bfd/libbfd.c b/bfd/libbfd.c
index 86366e496c5..e92ed5e18a2 100644
--- a/bfd/libbfd.c
+++ b/bfd/libbfd.c
@@ -1572,6 +1572,7 @@ _bfd_generic_init_private_section_data (bfd *ibfd ATTRIBUTE_UNUSED,
   return true;
 }
 
+#ifdef HAVE_MMAP
 uintptr_t _bfd_pagesize;
 uintptr_t _bfd_pagesize_m1;
 uintptr_t _bfd_minimum_mmap_size;
@@ -1587,3 +1588,4 @@ bfd_init_pagesize (void)
   /* The minimum section size to use mmap.  */
   _bfd_minimum_mmap_size = _bfd_pagesize * 4;
 }
+#endif
diff --git a/bfd/libbfd.h b/bfd/libbfd.h
index bed7d88d4ec..bfe3c6f1762 100644
--- a/bfd/libbfd.h
+++ b/bfd/libbfd.h
@@ -854,9 +854,11 @@ extern bfd_byte * _bfd_write_unsigned_leb128
 extern struct bfd_link_info *_bfd_get_link_info (bfd *)
   ATTRIBUTE_HIDDEN;
 
+#ifdef HAVE_MMAP
 extern uintptr_t _bfd_pagesize ATTRIBUTE_HIDDEN;
 extern uintptr_t _bfd_pagesize_m1 ATTRIBUTE_HIDDEN;
 extern uintptr_t _bfd_minimum_mmap_size ATTRIBUTE_HIDDEN;
+#endif
 
 #if GCC_VERSION >= 7000
 #define _bfd_mul_overflow(a, b, res) __builtin_mul_overflow (a, b, res)
diff --git a/bfd/lynx-core.c b/bfd/lynx-core.c
index 9ec5a0d2028..44d94ad8745 100644
--- a/bfd/lynx-core.c
+++ b/bfd/lynx-core.c
@@ -96,7 +96,7 @@ lynx_core_file_p (bfd *abfd)
   asection *newsect;
   size_t amt;
 
-  pagesize = _bfd_pagesize;	/* Serious cross-target issue here...  This
+  pagesize = getpagesize ();	/* Serious cross-target issue here...  This
 				   really needs to come from a system-specific
 				   header file.  */
 
-- 
2.44.0


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

* Re: [PATCH v2] bfd: Define pagesize variables only for mmap
  2024-04-09  2:39 [PATCH v2] bfd: Define pagesize variables only for mmap H.J. Lu
@ 2024-04-09  5:41 ` Alan Modra
  0 siblings, 0 replies; 2+ messages in thread
From: Alan Modra @ 2024-04-09  5:41 UTC (permalink / raw)
  To: H.J. Lu; +Cc: binutils, simon.marchi

On Mon, Apr 08, 2024 at 07:39:23PM -0700, H.J. Lu wrote:
> Define _bfd_pagesize, _bfd_pagesize_m1 and _bfd_minimum_mmap_size only
> if HAVE_MMAP is defined.
> 
> 	* libbfd-in.h (_bfd_pagesize): Declare only if HAVE_MMAP is
> 	defined.
> 	(_bfd_pagesize_m1): Likewise.
> 	(_bfd_minimum_mmap_size): Likewise.
> 	* libbfd.c (_bfd_pagesize): Define only if HAVE_MMAP is defined.
> 	(_bfd_pagesize_m1): Likewise.
> 	(_bfd_minimum_mmap_size): Likewise.
> 	(bfd_init_pagesize): Likewise.
> 	* lynx-core.c (lynx_core_file_p): Replace _bfd_pagesize with
> 	getpagesize.

OK.

-- 
Alan Modra
Australia Development Lab, IBM

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

end of thread, other threads:[~2024-04-09  5:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-09  2:39 [PATCH v2] bfd: Define pagesize variables only for mmap H.J. Lu
2024-04-09  5:41 ` 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).