public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: Alan Modra <amodra@gmail.com>
Cc: Simon Marchi <simon.marchi@polymtl.ca>,
	Binutils <binutils@sourceware.org>,
	 Noah Goldstein <goldstein.w.n@gmail.com>,
	Sam James <sam@gentoo.org>
Subject: Re: [PATCH] bfd: Define pagesize variables only for mmap
Date: Tue, 9 Apr 2024 07:25:46 -0700	[thread overview]
Message-ID: <CAMe9rOoX5AKB70t9=aD+wfds6MLm7+4WdTugA4kS17=0aEEcdQ@mail.gmail.com> (raw)
In-Reply-To: <ZhTWZpP3G9AfJFq6@squeak.grove.modra.org>

On Mon, Apr 8, 2024 at 10:47 PM Alan Modra <amodra@gmail.com> wrote:
>
> On Mon, Apr 08, 2024 at 07:49:26PM -0700, H.J. Lu wrote:
> > On Mon, Apr 8, 2024 at 3:55 PM Alan Modra <amodra@gmail.com> wrote:
> > >
> > > On Mon, Apr 08, 2024 at 07:26:37AM -0700, H.J. Lu wrote:
> > > > On Sun, Apr 7, 2024 at 8:58 PM Simon Marchi <simon.marchi@polymtl.ca> wrote:
> > > > > Since this commit, when building for --host=x86_64-w64-mingw32, I get:
> > > > >
> > > > >
> > > > > make[4]: Entering directory '/home/simark/build/binutils-gdb-x86_64-w64-mingw32/bfd'
> > > > >   CC       libbfd.lo
> > > > > /home/simark/src/binutils-gdb/bfd/libbfd.c: In function ‘bfd_init_pagesize’:
> > > > > /home/simark/src/binutils-gdb/bfd/libbfd.c:1583:19: error: implicit declaration of function ‘getpagesize’ [-Werror=implicit-function-declaration]
> > > > >  1583 |   _bfd_pagesize = getpagesize ();
> > > > >       |                   ^~~~~~~~~~~
> > > > >
> > > > > Simon
> > > >
> > > > Please try this patch.
> > >
> > > You need to revert the change to lynx-core.c as well.
> >
> > The v2 patch is at
> >
> > https://sourceware.org/pipermail/binutils/2024-April/133466.html
> >
> > > Somewhat related, why does binutils/elfedit.c depend on HAVE_MMAP?
> >
> > It uses mmap to update the ELF program header directly.
> >
> > > I run into failures with asan builds (ie. -fsanitize=address,undefined
> > > in CFLAGS and CXXFLAGS passed to configure).
> > > elfedit: unrecognized option '--enable-x86-feature'
> >
> > I built binutils with GCC 13 using
> >
> > CC="gcc -fsanitize=address,undefined" CXX="g++
> > -fsanitize=address,undefined"
> > /export/gnu/import/git/gitlab/x86-binutils/configure \
> > --disable-werror --disable-gprofng \
> > \
> > --enable-plugins --disable-gdb --disable-gdbserver
> > --disable-libbacktrace --disable-libdecnumber --disable-readline
> > --disable-sim --enable-mark-plt --with-sysroot=/ --with-system-zlib \
> > --prefix=/usr/local \
> > --with-local-prefix=/usr/local
> >
> > elfedit works:
> >
> > [hjl@gnu-cfl-3 binutils]$ ./elfedit --enable-x86-feature ibt xx
> > [hjl@gnu-cfl-3 binutils]$
> >
> > > Apparently HAVE_MMAP configury fusses too much, see this comment:
> > > gnulib/import/m4/mmap-anon.m4:  # Check for mmap(). Don't use AC_FUNC_MMAP, because it checks too much: it
> >
> > It checks MAP_ANONYMOUS, not mmap:
> >
> >   # Check for mmap(). Don't use AC_FUNC_MMAP, because it checks too much: it
> >   # fails on HP-UX 11, because MAP_FIXED mappings do not work. But this is
> >   # irrelevant for anonymous mappings.
>
> Yes, it isn't that.  I fail to get HAVE_MMAP for the rather more
> mundane reason that the config test fails with:
> =================================================================
> ==231796==ERROR: LeakSanitizer: detected memory leaks
>
> Direct leak of 4096 byte(s) in 1 object(s) allocated from:
>     #0 0x7cdd3d0defdf in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
>     #1 0x5750c7f6d72b in main /home/alan/build/gas-san/all/bfd/conftest.c:239
>
> Direct leak of 4096 byte(s) in 1 object(s) allocated from:
>     #0 0x7cdd3d0defdf in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
>     #1 0x5750c7f6d2e1 in main /home/alan/build/gas-san/all/bfd/conftest.c:190
>
> SUMMARY: AddressSanitizer: 8192 byte(s) leaked in 2 allocation(s).
>
> This can be avoided by
> export ASAN_OPTIONS=detect_leaks=0
>

A patch set is posted at

https://sourceware.org/pipermail/binutils/2024-April/133484.html

--
H.J.

  reply	other threads:[~2024-04-09 14:26 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-17 12:19 [PATCH v12 0/6] elf: Use mmap to map in section contents H.J. Lu
2024-03-17 12:19 ` [PATCH v12 1/6] elf: Use mmap to map in read-only sections H.J. Lu
2024-04-08  3:57   ` Simon Marchi
2024-04-08 14:26     ` [PATCH] bfd: Define pagesize variables only for mmap H.J. Lu
2024-04-08 22:55       ` Alan Modra
2024-04-09  2:49         ` H.J. Lu
2024-04-09  5:47           ` Alan Modra
2024-04-09 14:25             ` H.J. Lu [this message]
2024-03-17 12:19 ` [PATCH v12 2/6] elf: Add _bfd_elf_m[un]map_section_contents H.J. Lu
2024-03-17 12:19 ` [PATCH v12 3/6] elf: Use mmap to map in symbol and relocation tables H.J. Lu
2024-03-17 12:19 ` [PATCH v12 4/6] elf: Don't cache symbol nor relocation tables with mmap H.J. Lu
2024-03-17 12:19 ` [PATCH v12 5/6] elf: Always keep symbol table and relocation info for eh_frame H.J. Lu
2024-03-17 12:19 ` [PATCH v12 6/6] elf: Add _bfd_elf_link_m[un]map_section_contents H.J. Lu
2024-03-28 13:29 ` PING: [PATCH v12 0/6] elf: Use mmap to map in section contents H.J. Lu
2024-04-03 16:03   ` Nick Clifton
2024-04-04 13:12 ` Luis Machado
2024-04-04 13:53   ` H.J. Lu
2024-04-04 20:27   ` Joseph Myers
2024-04-04 22:22     ` Alan Modra
2024-04-04 22:43       ` Joseph Myers
2024-04-04 22:46         ` H.J. Lu
2024-04-04 23:20           ` H.J. Lu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAMe9rOoX5AKB70t9=aD+wfds6MLm7+4WdTugA4kS17=0aEEcdQ@mail.gmail.com' \
    --to=hjl.tools@gmail.com \
    --cc=amodra@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=goldstein.w.n@gmail.com \
    --cc=sam@gentoo.org \
    --cc=simon.marchi@polymtl.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).