Age | Commit message (Collapse) | Author | Files | Lines |
|
This patch provides some minimal thread-safety to BFD.
The BFD client can request thread-safety by providing a lock and
unlock function. The globals used during BFD creation (e.g.,
bfd_id_counter) are then locked, and the file descriptor cache is also
locked. A function to clean up any thread-local data is now provided
for BFD clients.
* bfd-in2.h: Regenerate.
* bfd.c (lock_fn, unlock_fn): New globals.
(bfd_thread_init, bfd_thread_cleanup, bfd_lock, bfd_unlock): New
functions.
* cache.c (bfd_cache_lookup_worker): Use _bfd_open_file_unlocked.
(cache_btell, cache_bseek, cache_bread, cache_bwrite): Lock
and unlock.
(cache_bclose): Add comment.
(cache_bflush, cache_bstat, cache_bmmap): Lock and unlock.
(_bfd_cache_init_unlocked): New function.
(bfd_cache_init): Use it. Lock and unlock.
(_bfd_cache_close_unlocked): New function.
(bfd_cache_close, bfd_cache_close_all): Use it. Lock and unlock.
(_bfd_open_file_unlocked): New function.
(bfd_open_file): Use it. Lock and unlock.
* doc/bfd.texi (BFD front end): Add Threading menu item.
* libbfd.h: Regenerate.
* opncls.c (_bfd_new_bfd): Lock and unlock.
* po/bfd.pot: Regenerate.
|
|
I noticed the regenerated BFD_RELOC_MICROBLAZE_32_NONE comment didn't
match that committed to bfd-in2.h, and was just going to regen
bfd-in2.h but then decided to do something about the silly formatting
of these comments in bfd-in2.h. eg. the BFD_RELOC_MICROBLAZE_32_NONE
comment:
-/* This is a 32 bit reloc that stores the 32 bit pc relative
-value in two words (with an imm instruction).No relocation is
-done here - only used for relaxing */
+ /* This is a 32 bit reloc that stores the 32 bit pc relative value in
+ two words (with an imm instruction). No relocation is done here -
+ only used for relaxing. */
BFD_RELOC_MICROBLAZE_32_NONE,
You'll notice how the second and third line of the original comment
aren't indented properly relative to the first line, and the whole
comment needs to be indented to match the code.
I've also edited reloc.c ENUMDOC paragraphs. Some of these had excess
indentation, presumably in an attempt to properly indent bfd-in2.h
comments but that fails due to chew.c removing leading whitespace
early by skip_white_and_stars. COMMENT was used in reloc.c to add
extra blank lines in bfd-in2.h. I've removed them too as I don't
think they add anything to readability of that file. (Perhaps more
usefully, they also add blank lines to libbfd.h separating relocs for
one target from others, but this isn't done consistently.)
* doc/chew.c (drop, idrop): Move earlier.
(strip_trailing_newlines): Check index before accessing array,
not after.
(wrap_comment): New function.
(main): Add "wrap_comment" intrinsic.
* doc/proto.str (ENUMDOC): Use wrap_comment.
(make_enum_header, ENDSENUM): Put start and end braces on
separate lines.
* reloc.c: Remove uses of COMMENT and edit ENUMDOC paragraphs.
* libbfd.h: Regenerate.
* bfd-in2.h: Regenerate.
|
|
PR 30806
bfd/
* doc/local.mk (doc/chew.stamp): Add CPPFLAGS_FOR_BUILD.
* Makefile.in: Regenerate.
binutils/
* Makefile.am (syslex_wrap.@OBJEXT@): Add CPPFLAGS_FOR_BUILD.
(sysinfo.@OBJEXT@): Likewise.
* Makefile.in: Regenerate.
|
|
This reverts commit 8bb23cdbb498ff645bb0937bc8c0cb89e9e5ebd8.
My earlier patch to simplifify the @node uses in the BFD manual didn't
take into account (1) that BFD doesn't use the ordinary texinfo
sectioning commands, and (2) that some users are stuck on very ancient
versions of makeinfo.
This patch reverts the change.
I went through the entire manual using the spacebar, trying to find
the original problem I reported in the change, but couldn't. I don't
know why. Anyway, all this means is that, with this reversion,
editing the node structure will be slightly less convenient.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30703
2023-08-30 Tom Tromey <tom@tromey.com>
PR binutils/30703
* doc/webassembly.texi, doc/bfd.texi: Revert 8bb23cdb, adding
parameters back to @node.
|
|
Pattern rules in doc/local.mk exist that specify how to make
libbfd.texi from libfd.h or libbfd.c. Since both files exist and the
libbfd.h rule is first, libbfd.h is used. libbfd.h doesn't contain
the documentation..
* doc/local.mk (doc/%stamp): Put rule making this from %.c
before %.h rule.
* Makefile.in: Regenerate.
* libbfd.c (Byte swapping routines): Don't omit description.
|
|
These were renamed from bfd_read and bfd_write back in 2001 when they
lost an unnecessary parameter. Rename them back, and get rid of a few
casts that are only needed without prototyped functions (K&R C).
|
|
doc/bfdint.texi and comments in the aout and som code about this
function are just wrong, and its name is not very apt. Better would
be _bfd_mostly_destroy, and we certainly should not be saying anything
about the possibility of later recreating anything lost by this
function. What's more, if _bfd_free_cached_info is called when
creating an archive map to reduce memory usage by throwing away
symbols, the target _close_and_cleanup function won't have access to
tdata or section bfd_user_data to tidy memory. This means most of the
target _close_and_cleanup function won't do anything, and therefore
sometimes will result in memory leaks.
This patch fixes the documentation problems and moves most of the
target _close_and_cleanup code to target _bfd_free_cached_info.
Another notable change is that bfd_generic_bfd_free_cached_info is now
defined as _bfd_free_cached_info rather than _bfd_bool_bfd_true,
ie. the default now frees objalloc memory.
|
|
bfd/doc/chew.c extracts documentation from source code comments
annotated with keywords, and generates much of bfd.h and libbfd.h from
those same comments. The docs have suffered from people (me too)
adding things like CODE_FRAGMENT to the source to put code into bfd.h
without realising that CODE_FRAGMENT also puts @example around said
code into the docs. So we have random senseless things in the docs.
This patch fixes that problem (well, the senseless things from
CODE_FRAGMENT), moves most of the code out of bfd-in.h, and improves a
few chew.c features. libbfd.h now automatically gets ATTRIBUTE_HIDDEN
prototypes, and indentation in bfd.h and libbfd.h is better.
|
|
Seen when building binutils with gcc -m32 on x86_64-linux.
chew.c: In function ‘print’:
chew.c:1434:59: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 3 has type ‘intptr_t’ {aka ‘int’} [-Wformat=]
1434 | fprintf (stderr, "print: illegal print destination `%ld'\n", *isp);
| ~~^ ~~~~
| | |
| | intptr_t {aka int}
| long int
| %d
* chew.c: Include inttypes.h.
(print): Use PRIdPTR for *isp.
|
|
FUNCTION is identical to func, so simplify doc.str.
2023-02-17 Tom Tromey <tom@tromey.com>
* doc/doc.str (FUNCTION): Call func.
|
|
Currently, if a function description spans a line, the resulting info
can look like this:
-- Function: long bfd_canonicalize_reloc
(bfd *abfd, asection *sec, arelent **loc, asymbol **syms); Call the
back end associated with the open BFD ABFD and translate the
external form of the relocation information attached to SEC into
the internal canonical form. Place the table into memory at LOC,
That is, the function prototype runs together with the text in an ugly
way. This patch fixes this by introducing a new primitive, so that
the generated Texinfo can be a bit nicer. Now this output looks like:
-- Function: long bfd_canonicalize_reloc (bfd *abfd, asection *sec,
arelent **loc, asymbol **syms);
Call the back end associated with the open BFD ABFD and translate
the external form of the relocation information attached to SEC
2023-02-17 Tom Tromey <tom@tromey.com>
* doc/doc.str (SYNOPSIS): Use collapse_whitespace.
* doc/chew.c (collapse_whitespace): New function.
(main): Register collapse_whitespace.
|
|
An earlier patch of mine introduced a memory leak in chew. The bug
was that the new "variable" word didn't free the following word. This
patch fixes it by arranging to transfer ownership of the name to the
variable itself.
* doc/chew.c (add_variable): New function, from
add_intrinsic_variable.
(add_intrinsic_variable): Call add_variable.
(compile): Call add_variable.
|
|
When reading the BFD manual, I noticed text like this:
-- Function: bool bfd_close (bfd *abfd);
Close a BFD. If the BFD was open for writing, then pending
operations are completed and the file written out and closed. If
...
*Returns*
'TRUE' is returned if all is ok, otherwise 'FALSE'.
The *Returns*, like the *Synopsis* in the earlier patch, is
un-info-like. It's also used inconsistently.
This patch removes all the uses of the RETURNS word and removes it
entirely from the chew scripts. Now this example reads:
-- Function: bool bfd_close (bfd *abfd);
Close a BFD. If the BFD was open for writing, then pending
operations are completed and the file written out and closed. If
...
'TRUE' is returned if all is ok, otherwise 'FALSE'.
In a few cases I had to slightly reword the comment. There were also
a couple of cases where there was redundant text. In these cases I
just dropped the RETURNS copy.
2023-02-07 Tom Tromey <tom@tromey.com>
* bfd.c, cache.c, compress.c, opncls.c: Remove RETURNS from
documentation comments.
* doc/doc.str, doc/proto.str (RETURNS): Remove.
|
|
When reading the BFD info manual, function definitions looked very
strange to me:
*Synopsis*
long bfd_get_mtime (bfd *abfd);
*Description*
Return the file modification time (as read from the file system, or from
the archive header for archive members).
The *Synopsis* and *Description* text in particular is very un-info-like.
To fix this, I tried removing the *Synopsis* text and having FUNCTION
use @deftypefn instead. However, this ended up requiring some new
state, because SYNOPSIS can appear without FUNCTION. This in turn
required "catstrif" (I considered adding FORTH-style if-else-then, but
in the end decided on an ad hoc approach).
After this the result looks like:
-- Function: long bfd_get_mtime (bfd *abfd);
Return the file modification time (as read from the file system, or
from the archive header for archive members).
This patch also reorders a few documentation comments to ensure that
SYNOPSIS comes before DESCRIPTION. This is the more common style and
is also now required by doc.str.
2023-02-07 Tom Tromey <tom@tromey.com>
* syms.c (bfd_decode_symclass, bfd_is_undefined_symclass)
(bfd_symbol_info): Reorder documentation comment.
* doc/doc.str (synopsis_seen): New variable.
(SYNOPSIS): Set synopsis_seen. Emit @deftypefn.
(DESCRIPTION): Use synopsis_seen.
* doc/chew.c (catstrif): New function.
(main): Add catstrif intrinsic.
(compile): Recognize "variable" command.
|
|
Currently, internalmode is a special word to set an internal state
variable. Because this series adds variables anyway, change this to
be a variable instead.
I saw some commits in the history that made sure that chew did not
leak memory, so I put some extra effort into trying to handle this for
variables as well.
2023-02-07 Tom Tromey <tom@tromey.com>
* doc/proto.str (external, internal, ifinternal, ENUMEQ, ENUMDOC):
Update.
* doc/chew.c (internalmode): Remove.
(add_intrinsic_variable): New function.
(main): Add internalmode as intrinsic.
(internal_mode): Remove global.
(maybecatstr): Update.
(free_words): Free variables.
|
|
To implement variables in chew, it's convenient to have a
pointer-sized integer on the stack. To this end, use intptr_t rather
than long.
2023-02-07 Tom Tromey <tom@tromey.com>
* doc/chew.c (pcu) <l>: Now intptr_t.
(internal_mode, istack, isp): Likewise.
(bang, atsign): Use intptr_t.
|
|
The chew "paramstuff" word has been a no-op since:
commit c58b95236ce4c9345c4fa76e7ef16762e5229380
Author: Alan Modra <amodra@gmail.com>
Date: Sun Jun 29 10:06:40 2003 +0000
Convert to C90 and a few tweaks.
Remove it and its one use.
2023-02-07 Tom Tromey <tom@tromey.com>
* doc/proto.str (SYNOPSIS): Don't use paramstuff.
* doc/chew.c (paramstuff): Remove.
(main): Don't add paramstuff intrinsic.
|
|
The .str script files don't have copyright headers, but I think they
should. I used the same dates that chew.c uses, which I think makes
sense because these are inputs to chew.
2023-02-07 Tom Tromey <tom@tromey.com>
* doc/doc.str, doc/proto.str: Add copyright header.
|
|
The BFD docs currently specify all the parameters to @node. However,
this results in bad navigation in certain nodes -- the "space" command
in info doesn't know how to find the next node.
I think this style of @node is a leftover from ancient times.
Makeinfo can figure out the node structure on its own now, so simplify
everything to a single-argument @node.
2023-02-07 Tom Tromey <tom@tromey.com>
* doc/webassembly.texi (File layout): Remove second argument from
@node.
* doc/bfd.texi: Use single-argument @node everywhere.
|
|
I couldn't see that H_CFLAGS is defined anywhere, so remove it.
2023-02-07 Tom Tromey <tom@tromey.com>
* Makefile.in: Rebuild.
* doc/local.mk (%D%/chew.stamp): Don't use H_CFLAGS.
|
|
Commit b1c95bc4dd73 resulted in
...bfd.texi:246: @include: could not find init.texi
which went unnoticed due to not building in a clean directory.
This fixes the problem by moving bfd_init earlier, giving it a
doc node, and stitching the nodes back together.
* bfd.c (bfd_init): Move earlier. Give it a doc inode.
Adjust other inodes to suit.
* doc/bfd.texi: Don't include init.texi. Adjust nodes to suit.
|
|
init.c contains just one function that doesn't do much. Move it to
bfd.c and give it something to do, initialising static state. So far
the only initialisation is for bfd.c static variables.
The idea behind reinitialising state is to see whether some set of
flaky oss-fuzz crashes go away. oss-fuzz stresses binutils in ways
that can't occur in reality, feeding multiple testcases into the
internals of binutils. So one testcase may affect the result of the
next testcase.
* init.c: Delete file. Move bfd_init to..
* bfd.c (bfd_init): ..here. Init static variables.
* Makefile.am (BFD32_LIBS): Remove init.lo.
(BFD32_LIBS_CFILES, BFD_H_FILES): Remove init.c.
* doc/local.mk: Remove mention of init.texi and init.c.
* Makefile.in: Regenerate.
* bfd-in2.h: Regenerate.
* po/SRC-POTFILES.in: Regenerate.
|
|
Delete a few files only used for obsolete targets, and tidy config,
xfails and other pieces of support specific to those targets. And
since I was editing target triplets in test files, fix the nm
alpha-linuxecoff fails.
|
|
The newer update-copyright.py fixes file encoding too, removing cr/lf
on binutils/bfdtest2.c and ld/testsuite/ld-cygwin/exe-export.exp, and
embedded cr in binutils/testsuite/binutils-all/ar.exp string match.
|
|
We can't use libiberty.a in chew. libiberty is a host library, chew
a build program. Partly revert commit 7273d78f3f7a, instead define
local versions of the libiberty functions. ansidecl.h also isn't
needed.
* doc/chew.c: Don't include libiberty.h or ansidecl.h.
(xmalloc, xrealloc, xstrdup): New functions.
* doc/local.mk (LIBIBERTY): Don't define or use.
* Makefile.in: Regenerate.
|
|
This fixes -Wpedantic warnings in chew.c. Conversion between function
and object pointers is not guaranteed. They can even be different
sizes, not that we're likely to encounter build machines like that
nowadays.
PR 29194
* doc/chew.c (pcu): New union typedef.
(dict_type, pc): Use it here. Adjust uses of pc.
(add_to_definition): Make "word" param a pcu. Adjust all uses
of function.
(stinst_type): Delete.
|
|
Catch out of memory.
* doc/chew.c: Include libibery.h.
(init_string_with_size, nextword): Replace malloc with xmalloc.
(newentry, add_to_definition): Likewise.
(catchar, catbuf): Replace realloc with xrealloc.
(add_intrinsic): Replace strdup with xstrdup.
* doc/local.mk (LIBIBERTY): Define.
(chew): Link against libiberty.
* Makefile.in: Regenerate.
|
|
* doc/chew.c: Update function definitions to ISO C, remove
now unnecessary prototypes.
|
|
This also removes some unused variables, and deletes support for the
"var" keyword which isn't used and was broken. (No means to set
variables, and add_var used push_number inconsistent with its use
elsewhere.)
* doc/chew.c: Move typedefs before variables, variables before
functions.
(die): Move earlier.
(word_type, sstack, ssp): Delete.
(dict_type): Delete var field.
(add_var): Delete.
(compile): Remove "var" support.
|
|
Make bfd.stamp depend on source bfd.texi to avoid regenerating
doc/bfd.info for each make run.
PR binutils/28807
* Makefile.in: Regenerate.
* doc/local.mk (%D%/bfd.stamp): Depend on $(srcdir)/%D%/bfd.texi.
|
|
PR binutils/28807
* Makefile.in: Regenerate.
* doc/local.mk (AM_MAKEINFOFLAGS): Add -I "$(srcdir)/%D%" -I %D%.
(TEXI2DVI): New.
(%D%/bfd.texi): Removed.
(doc/bfd/index.html): Remove -I$(srcdir). Replace bfd.texi with
%D%/bfd.texi.
|
|
bfd/
* doc/local.mk (%D%/bfdver.texi): Add mkdir command.
|
|
Rename bfdlib_LTLIBRARIES and bfdinclude_HEADERS to lib_LTLIBRARIES and
include_HEADERS to fix the missing installed library and header files in
bfd caused by
commit bd32be01c997f686ab0b53f0640eaa0aeb61fbd3
Author: Mike Frysinger <vapier@gentoo.org>
Date: Fri Dec 3 00:23:20 2021 -0500
bfd: merge doc subdir up a level
PR binutils/28807
* Makefile.am (bfdlib_LTLIBRARIES): Renamed to ...
(lib_LTLIBRARIES): This.
(bfdinclude_HEADERS): Renamed to ...
(include_HEADERS): This.
* Makefile.in: Regenerate.
* doc/local.mk (install): Removed.
|
|
This avoids a recursive make into the doc subdir and speeds up the
build slightly. It also allows for more parallelism.
|
|
This is a generated file name from a correspondingly named C file.
Rename it to avoid unique build rules since there's no difference
to the generated manual.
|
|
This unifies boilerplate rules for most files with pattern rules.
|
|
regenerate files.
|
|
The result of running etc/update-copyright.py --this-year, fixing all
the files whose mode is changed by the script, plus a build with
--enable-maintainer-mode --enable-cgen-maint=yes, then checking
out */po/*.pot which we don't update frequently.
The copy of cgen was with commit d1dd5fcc38ead reverted as that commit
breaks building of bfp opcodes files.
|
|
Move the 64-bit bfd logic out of bfd/configure.ac and into bfd64.m4
under config so it can be shared between all the other subdirs.
This replaces want64 with enable_64_bit_bfd which was already being
declared, but not used directly.
|
|
The logic between these rules are extremely similar, so unify them
into a single variable by leveraging make $@ and $< variables.
Also add automake silent rule support while we're here.
|
|
The rules for rebuilding the bfd headers live in the doc/ subdir
(most likely) because they rely on the chew & related tools. But
we can collapse them into the main Makefile while keeping the tools
in the doc subdir easily enough. This makes the code simpler and
allows for rebuilding them in parallel.
Also add automake silent rule support while we're here.
|
|
These have been around for decades but don't appear to be used, and
trying to build them (e.g. `make archive.p archive.ip`) doesn't work,
so just delete it all.
|
|
It matters not at all if pc is incremented from its initial NULL
value, but avoid this silly runtime ubsan error.
* doc/chew.c (perform): Avoid incrementing NULL pc.
|
|
Use the pattern from other projects where we generate the html pages
in a dir named the same as the project. So now we have:
gas/doc/gas.html - single html page
gas/doc/gas/ - multiple html pages
This works for projects that have a doc/ subdir already, but gprof &
ld require a little tweaking since they generate their docs in their
respective toplevels.
|
|
This better matches other GNU projects like autoconf/automake where
the html manual is the single page form. We'll support the multi-page
form in a follow up change.
|
|
If we require C99 for binutils then stdint.h is available.
bfd/
* .gitignore: Delete bfd_stdint.h entry.
* Makefile.am (bfdinclude_HEADERS): Delete bfd_stdint.h.
(BUILD_HFILES, LOCAL_H_DEPS): Likewise.
* bfd-in.h: Include stdint.h in place of bfd_stdint.h.
* configure.ac: Don't invoke GCC_HEADER_STDINT.
* configure.com: Don't create bfd_stdint.h.
* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* bfd-in2.h: Regenerate.
* config.in: Regenerate.
* configure: Regenerate.
* doc/Makefile.in: Regenerate.
* po/BLD-POTFILES.in: Regenerate.
binutils/
* coffdump.c: Include stdint.h in place of bfd_stdint.h.
* dwarf.c: Likewise.
gas/
* config/tc-aarch64.c: Include stdint.h in place of bfd_stdint.h.
* config/tc-crx.c: Likewise.
* config/tc-nds32.h: Likewise.
include/
* cgen/basic-modes.h: Include stdint.h in place of bfd_stdint.h.
* elf/nfp.h: Likewise.
* opcode/aarch64.h: Likewise.
* opcode/cgen.h: Likewise.
* opcode/nfp.h: Likewise.
* opcode/ppc.h: Likewise.
ld/
* elf-hints-local.h: Include stdint.h in place of bfd_stdint.h.
* emultempl/nds32elf.em: Likewise.
* testsuite/ld-elf/mbind2b.c: Likewise.
* testsuite/ld-elf/pr18718.c: Likewise.
* testsuite/ld-elf/pr18720a.c: Likewise.
* testsuite/ld-elf/pr25749-1.c: Likewise.
* testsuite/ld-elf/pr25749-1a.c: Likewise.
* testsuite/ld-elf/pr25749-1b.c: Likewise.
* testsuite/ld-elf/pr25749-1c.c: Likewise.
* testsuite/ld-elf/pr25749-1d.c: Likewise.
* testsuite/ld-elf/pr25749-2.c: Likewise.
* testsuite/ld-elf/pr25754-1a.c: Likewise.
* testsuite/ld-elf/pr25754-2a.c: Likewise.
* testsuite/ld-elf/pr25754-3a.c: Likewise.
* testsuite/ld-elf/pr25754-4a.c: Likewise.
* testsuite/ld-elf/pr25754-5a.c: Likewise.
* testsuite/ld-elf/pr25754-6a.c: Likewise.
opcodes/
* aarch64-dis.c: Include stdint.h in place of bfd_stdint.h.
* aarch64-dis.h: Likewise.
* aarch64-opc.c: Likewise.
* avr-dis.c: Likewise.
* csky-dis.c: Likewise.
* nds32-asm.c: Likewise.
* nds32-dis.c: Likewise.
* nfp-dis.c: Likewise.
* riscv-dis.c: Likewise.
* s12z-dis.c: Likewise.
* wasm32-dis.c: Likewise.
|
|
"cp -p" has been observed to fail on Cygwin when the build tree is on a
local drive but the sources are on a Samba share. We don't really need
full copies of the files here - symlinks suffice.
|
|
bfd/
* Makefile.in: Regenerate.
* doc/Makefile.in: Regenerate.
binutils/
* Makefile.in: Regenerate.
* doc/Makefile.in: Regenerate.
gas/
* Makefile.in: Regenerate.
* Makefile.in: Regenerate.
gprof/
* Makefile.in: Regenerate.
ld/
* Makefile.in: Regenerate.
libctf/
* Makefile.in: Regenerate.
opcodes/
* Makefile.in: Regenerate.
|
|
|
|
GDB currently doesn't build on 32-bit Solaris:
* On Solaris 11.4/x86:
In file included from /usr/include/sys/procfs.h:26,
from /vol/src/gnu/gdb/hg/master/dist/gdb/i386-sol2-nat.c:24:
/usr/include/sys/old_procfs.h:31:2: error: #error "Cannot use procfs in the large file compilation environment"
#error "Cannot use procfs in the large file compilation environment"
^~~~~
* On Solaris 11.3/x86 there are several more instances of this.
The interaction between procfs and large-file support historically has
been a royal mess on Solaris:
* There are two versions of the procfs interface:
** The old ioctl-based /proc, deprecated and not used any longer in
either gdb or binutils.
** The `new' (introduced in Solaris 2.6, 1997) structured /proc.
* There are two headers one can possibly include:
** <procfs.h> which only provides the structured /proc, definining
_STRUCTURED_PROC=1 and then including ...
** <sys/procfs.h> which defaults to _STRUCTURED_PROC=0, the ioctl-based
/proc, but provides structured /proc if _STRUCTURED_PROC == 1.
* procfs and the large-file environment didn't go well together:
** Until Solaris 11.3, <sys/procfs.h> would always #error in 32-bit
compilations when the large-file environment was active
(_FILE_OFFSET_BITS == 64).
** In both Solaris 11.4 and Illumos, this restriction was lifted for
structured /proc.
So one has to be careful always to define _STRUCTURED_PROC=1 when
testing for or using <sys/procfs.h> on Solaris. As the errors above
show, this isn't always the case in binutils-gdb right now.
Also one may need to disable large-file support for 32-bit compilations
on Solaris. config/largefile.m4 meant to do this by wrapping the
AC_SYS_LARGEFILE autoconf macro with appropriate checks, yielding
ACX_LARGEFILE. Unfortunately the macro doesn't always succeed because
it neglects the _STRUCTURED_PROC part.
To make things even worse, since GCC 9 g++ predefines
_FILE_OFFSET_BITS=64 on Solaris. So even if largefile.m4 deciced not to
enable large-file support, this has no effect, breaking the gdb build.
This patch addresses all this as follows:
* All tests for the <sys/procfs.h> header are made with
_STRUCTURED_PROC=1, the definition going into the various config.h
files instead of having to make them (and sometimes failing) in the
affected sources.
* To cope with the g++ predefine of _FILE_OFFSET_BITS=64,
-U_FILE_OFFSET_BITS is added to various *_CPPFLAGS variables. It had
been far easier to have just
#undef _FILE_OFFSET_BITS
in config.h, but unfortunately such a construct in config.in is
commented by config.status irrespective of indentation and whitespace
if large-file support is disabled. I found no way around this and
putting the #undef in several global headers for bfd, binutils, ld,
and gdb seemed way more invasive.
* Last, the applicability check in largefile.m4 was modified only to
disable largefile support if really needed. To do so, it checks if
<sys/procfs.h> compiles with _FILE_OFFSET_BITS=64 defined. If it
doesn't, the disabling only happens if gdb exists in-tree and isn't
disabled, otherwise (building binutils from a tarball), there's no
conflict.
What initially confused me was the check for $plugins here, which
originally caused the disabling not to take place. Since AC_PLUGINGS
does enable plugin support if <dlfcn.h> exists (which it does on
Solaris), the disabling never happened.
I could find no explanation why the linker plugin needs large-file
support but thought it would be enough if gld and GCC's lto-plugin
agreed on the _FILE_OFFSET_BITS value. Unfortunately, that's not
enough: lto-plugin uses the simple-object interface from libiberty,
which includes off_t arguments. So to fully disable large-file
support would mean also disabling it in libiberty and its users: gcc
and libstdc++-v3. This seems highly undesirable, so I decided to
disable the linker plugin instead if large-file support won't work.
The patch allows binutils+gdb to build on i386-pc-solaris2.11 (both
Solaris 11.3 and 11.4, using GCC 9.3.0 which is the worst case due to
predefined _FILE_OFFSET_BITS=64). Also regtested on
amd64-pc-solaris2.11 (again on Solaris 11.3 and 11.4),
x86_64-pc-linux-gnu and i686-pc-linux-gnu.
config:
* largefile.m4 (ACX_LARGEFILE) <sparc-*-solaris*|i?86-*-solaris*>:
Check for <sys/procfs.h> incompatilibity with large-file support
on Solaris.
Only disable large-file support and perhaps plugins if needed.
Set, substitute LARGEFILE_CPPFLAGS if so.
bfd:
* bfd.m4 (BFD_SYS_PROCFS_H): New macro.
(BFD_HAVE_SYS_PROCFS_TYPE): Require BFD_SYS_PROCFS_H.
Don't define _STRUCTURED_PROC.
(BFD_HAVE_SYS_PROCFS_TYPE_MEMBER): Likewise.
* elf.c [HAVE_SYS_PROCFS_H] (_STRUCTURED_PROC): Don't define.
* configure.ac: Use BFD_SYS_PROCFS_H to check for <sys/procfs.h>.
* configure, config.in: Regenerate.
* Makefile.am (AM_CPPFLAGS): Add LARGEFILE_CPPFLAGS.
* Makefile.in, doc/Makefile.in: Regenerate.
binutils:
* Makefile.am (AM_CPPFLAGS): Add LARGEFILE_CPPFLAGS.
* Makefile.in, doc/Makefile.in: Regenerate.
* configure: Regenerate.
gas:
* Makefile.am (AM_CPPFLAGS): Add LARGEFILE_CPPFLAGS.
* Makefile.in, doc/Makefile.in: Regenerate.
* configure: Regenerate.
gdb:
* proc-api.c (_STRUCTURED_PROC): Don't define.
* proc-events.c: Likewise.
* proc-flags.c: Likewise.
* proc-why.c: Likewise.
* procfs.c: Likewise.
* Makefile.in (INTERNAL_CPPFLAGS): Add LARGEFILE_CPPFLAGS.
* configure, config.in: Regenerate.
gdbserver:
* configure, config.in: Regenerate.
gdbsupport:
* Makefile.am (AM_CPPFLAGS): Add LARGEFILE_CPPFLAGS.
* common.m4 (GDB_AC_COMMON): Use BFD_SYS_PROCFS_H to check for
<sys/procfs.h>.
* Makefile.in: Regenerate.
* configure, config.in: Regenerate.
gnulib:
* configure.ac: Run ACX_LARGEFILE before gl_EARLY.
* configure: Regenerate.
gprof:
* Makefile.am (AM_CPPFLAGS): Add LARGEFILE_CPPFLAGS.
* Makefile.in: Regenerate.
* configure: Regenerate.
ld:
* Makefile.am (AM_CPPFLAGS): Add LARGEFILE_CPPFLAGS.
* Makefile.in: Regenerate.
* configure: Regenerate.
|