mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-21 04:42:53 +08:00
7eea9d3bdb
Jose Marchesi noted that the traditional-Unix error array in ctf-error.c introduces one reloc per error to initialize the array: 58 so far. We can reduce this to zero using an array of carefully-sized individual members which is used to construct a string table, that is then referenced by the lookup functions: but doing this automatically is a pain. Bruno Haible wrote suitable code years ago: I got permission to reuse it (Bruno says "... which I hereby put in the public domain"); I modified it a tiny bit (similarly to what Ulrich Drepper did in the dsohowto text, but I redid it from scratch), commented it up a bit, and shifted the error table into that form, migrating it into the new file ctf-error.h. This has the advantage that it spotted both typos in the text of the errors in the comments in ctf-api.h and typos in the error defines in the comments in ctf-error.c, and places where the two were simply not in sync. All are now fixed. One new constant exists in ctf-api.h: CTF_NERR, since the old method of working out the number of errors in ctf-error.c was no longer usable, and it seems that the number of CTF errors is something users might reasonably want as well. It should be pretty easy to keep up to date as new errors are introduced. include/ * ctf-api.h (ECTF_*): Improve comments. (ECTF_NERR): New. libctf/ * ctf-error.c: Include <stddef.h>, for offsetof. (_ctf_errlist): Migrate to... (_ctf_errlist_t): ... this. (_ctf_erridx): New, indexes into _ctf_errlist_t. (_ctf_nerr): Remove. (ctf_errmsg): Adjust accordingly. * Makefile.am (BUILT_SOURCES): Note... (ctf-error.h): ... this new rule. * Makefile.in: Regenerate. * mkerrors.sed: New, process ctf-api.h to generate ctf-error.h. * .gitignore: New, ignore ctf-error.h.
60 lines
2.2 KiB
Makefile
60 lines
2.2 KiB
Makefile
## Process this file with automake to produce Makefile.in.
|
|
#
|
|
# Copyright (C) 2019-2020 Free Software Foundation, Inc.
|
|
#
|
|
# This file is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program; see the file COPYING. If not see
|
|
# <http://www.gnu.org/licenses/>.
|
|
#
|
|
|
|
ACLOCAL_AMFLAGS = -I .. -I ../config -I ../bfd
|
|
|
|
AUTOMAKE_OPTIONS = foreign no-texinfo.tex
|
|
|
|
# This is where we get zlib from. zlibdir is -L../zlib and zlibinc is
|
|
# -I../zlib, unless we were configured with --with-system-zlib, in which
|
|
# case both are empty.
|
|
ZLIB = @zlibdir@ -lz
|
|
ZLIBINC = @zlibinc@
|
|
|
|
INCDIR = $(srcdir)/../include
|
|
AM_CPPFLAGS = -D_GNU_SOURCE -I$(srcdir) -I$(srcdir)/../include -I$(srcdir)/../bfd -I../bfd
|
|
AM_CFLAGS = -std=gnu99 @ac_libctf_warn_cflags@ @warn@ @c_warn@ @WARN_PEDANTIC@ @WERROR@ $(ZLIBINC)
|
|
|
|
if INSTALL_LIBBFD
|
|
lib_LTLIBRARIES = libctf.la libctf-nobfd.la
|
|
include_HEADERS = $(INCDIR)/ctf.h $(INCDIR)/ctf-api.h
|
|
else
|
|
include_HEADERS =
|
|
noinst_LTLIBRARIES = libctf.la libctf-nobfd.la
|
|
endif
|
|
|
|
libctf_nobfd_la_LIBADD = @SHARED_LIBADD@ $(ZLIB)
|
|
libctf_nobfd_la_LDFLAGS = -version-info 0:0:0 @SHARED_LDFLAGS@ @VERSION_FLAGS@
|
|
libctf_nobfd_la_SOURCES = ctf-archive.c ctf-dump.c ctf-create.c ctf-decl.c ctf-error.c \
|
|
ctf-hash.c ctf-labels.c ctf-link.c ctf-lookup.c ctf-open.c \
|
|
ctf-string.c ctf-subr.c ctf-types.c ctf-util.c
|
|
if NEED_CTF_QSORT_R
|
|
libctf_nobfd_la_SOURCES += ctf-qsort_r.c
|
|
endif
|
|
|
|
libctf_la_LIBADD = @BFD_LIBADD@ $(libctf_nobfd_la_LIBADD)
|
|
libctf_la_DEPENDENCIES = @BFD_DEPENDENCIES@
|
|
libctf_la_LDFLAGS = $(libctf_nobfd_la_LDFLAGS)
|
|
libctf_la_SOURCES = $(libctf_nobfd_la_SOURCES) ctf-open-bfd.c
|
|
|
|
BUILT_SOURCES = ctf-error.h
|
|
|
|
ctf-error.h: $(srcdir)/mkerrors.sed $(srcdir)/../include/ctf-api.h
|
|
sed -nf $(srcdir)/mkerrors.sed < $(srcdir)/../include/ctf-api.h > $@
|