Take only libelf from elfutils and simplify the build system

This commit is contained in:
Wolfgang Thaller 2017-09-28 00:10:50 +02:00
parent 8240fa9358
commit bf7325099e
149 changed files with 119 additions and 1377 deletions

View File

@ -55,13 +55,7 @@ configure_file(cmake/intree.toolchain.cmake.in cmake/intree.toolchain.cmake @ONL
configure_file(cmake/intreeppc.toolchain.cmake.in cmake/intreeppc.toolchain.cmake @ONLY)
configure_file(cmake/intreecarbon.toolchain.cmake.in cmake/intreecarbon.toolchain.cmake @ONLY)
file(GLOB ELF_FILES elfutils/libelf/*.c elfutils/libelf/*.h)
add_library(ELF ${ELF_FILES}
)
target_include_directories(ELF PRIVATE elfutils/libelf)
target_link_libraries(ELF -lz)
target_compile_definitions(ELF PRIVATE HAVE_CONFIG_H)
add_subdirectory(libelf)
add_subdirectory(ResourceFiles)
add_subdirectory(MakeAPPL)
add_subdirectory(Rez)

View File

@ -104,7 +104,6 @@ if [ $SKIP_THIRDPARTY != false ]; then
if [ $BUILD_68K != false ]; then
if [ ! -d binutils-build ]; then MISSING=true; fi
if [ ! -d gcc-build ]; then MISSING=true; fi
if [ ! -d elf2flt-build ]; then MISSING=true; fi
fi
if [ $BUILD_PPC != false ]; then
if [ ! -d binutils-build-ppc ]; then MISSING=true; fi
@ -239,7 +238,7 @@ if [ $BUILD_CARBON != false ]; then
fi
fi
##################### Third-Party components: binutils, gcc, elfutils, hfsutils
##################### Third-Party components: binutils, gcc, hfsutils
if [ $SKIP_THIRDPARTY != true ]; then
@ -247,7 +246,7 @@ if [ $SKIP_THIRDPARTY != true ]; then
rm -rf toolchain
mkdir -p toolchain
# Components needed for targeting 68K: binutils, gcc, elfutils, elf2flt
# Components needed for targeting 68K: binutils, gcc
if [ $BUILD_68K != false ]; then
# present-day Mac users are likely to install dependencies
@ -279,13 +278,6 @@ if [ $SKIP_THIRDPARTY != true ]; then
unset CPPFLAGS
unset LDFLAGS
mkdir -p elfutils-build
cd elfutils-build
$SRC/elfutils/configure --prefix=$PREFIX
make -j8
make install
cd ..
# Move the real linker aside and install symlinks to Elf2Mac
# (Elf2Mac is built by cmake below)
mv $PREFIX/bin/m68k-apple-macos-ld $PREFIX/bin/m68k-apple-macos-ld.real
@ -293,13 +285,9 @@ if [ $SKIP_THIRDPARTY != true ]; then
ln -s $PREFIX/bin/Elf2Mac $PREFIX/bin/m68k-apple-macos-ld
ln -s $PREFIX/bin/Elf2Mac $PREFIX/m68k-apple-macos/bin/ld
unset CFLAGS
unset CPPFLAGS
if [ $CLEAN_AFTER_BUILD != false ]; then
rm -rf binutils-build
rm -rf gcc-build
rm -rf elf2flt-build
fi
fi

View File

@ -1,131 +0,0 @@
## Process this file with automake to create Makefile.in
##
## Copyright (C) 1996-2010, 2015 Red Hat, Inc.
## This file is part of elfutils.
##
## This file is free software; you can redistribute it and/or modify
## it under the terms of either
##
## * the GNU Lesser General Public License as published by the Free
## Software Foundation; either version 3 of the License, or (at
## your option) any later version
##
## or
##
## * 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
##
## or both in parallel, as here.
##
## elfutils 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 copies of the GNU General Public License and
## the GNU Lesser General Public License along with this program. If
## not, see <http://www.gnu.org/licenses/>.
##
include $(top_srcdir)/config/eu.am
if BUILD_STATIC
AM_CFLAGS += -fPIC
endif
GCC_INCLUDE = -I$(shell $(CC) -print-file-name=include)
VERSION = 1
lib_LIBRARIES = libelf.a
noinst_LIBRARIES = libelf_pic.a
noinst_PROGRAMS = $(noinst_LIBRARIES:_pic.a=.so)
include_HEADERS = libelf.h gelf.h nlist.h
pkginclude_HEADERS = elf-knowledge.h
libelf_a_SOURCES = elf_version.c elf_hash.c elf_error.c elf_fill.c \
elf_begin.c elf_next.c elf_rand.c elf_end.c elf_kind.c \
gelf_getclass.c elf_getbase.c elf_getident.c \
elf32_fsize.c elf64_fsize.c gelf_fsize.c \
elf32_xlatetof.c elf32_xlatetom.c elf64_xlatetof.c \
elf64_xlatetom.c gelf_xlate.c \
elf32_getehdr.c elf64_getehdr.c gelf_getehdr.c \
elf32_newehdr.c elf64_newehdr.c gelf_newehdr.c \
gelf_update_ehdr.c \
elf32_getphdr.c elf64_getphdr.c gelf_getphdr.c \
elf32_newphdr.c elf64_newphdr.c gelf_newphdr.c \
gelf_update_phdr.c \
elf_getarhdr.c elf_getarsym.c \
elf_rawfile.c elf_readall.c elf_cntl.c \
elf_getscn.c elf_nextscn.c elf_ndxscn.c elf_newscn.c \
elf32_getshdr.c elf64_getshdr.c gelf_getshdr.c \
gelf_update_shdr.c \
elf_strptr.c elf_rawdata.c elf_getdata.c elf_newdata.c \
elf_getdata_rawchunk.c \
elf_flagelf.c elf_flagehdr.c elf_flagphdr.c elf_flagscn.c \
elf_flagshdr.c elf_flagdata.c elf_memory.c \
elf_update.c elf32_updatenull.c elf64_updatenull.c \
elf32_updatefile.c elf64_updatefile.c \
gelf_getsym.c gelf_update_sym.c \
gelf_getversym.c gelf_getverneed.c gelf_getvernaux.c \
gelf_getverdef.c gelf_getverdaux.c \
gelf_getrel.c gelf_getrela.c \
gelf_update_rel.c gelf_update_rela.c \
gelf_getdyn.c gelf_update_dyn.c \
gelf_getmove.c gelf_update_move.c \
gelf_getsyminfo.c gelf_update_syminfo.c \
gelf_getauxv.c gelf_update_auxv.c \
gelf_getnote.c \
gelf_xlatetof.c gelf_xlatetom.c \
nlist.c \
gelf_getsymshndx.c gelf_update_symshndx.c \
gelf_update_versym.c gelf_update_verneed.c \
gelf_update_vernaux.c gelf_update_verdef.c \
gelf_update_verdaux.c \
elf_getphdrnum.c elf_getshdrnum.c elf_getshdrstrndx.c \
gelf_checksum.c elf32_checksum.c elf64_checksum.c \
libelf_crc32.c libelf_next_prime.c \
elf_clone.c \
gelf_getlib.c gelf_update_lib.c \
elf32_offscn.c elf64_offscn.c gelf_offscn.c \
elf_getaroff.c \
elf_gnu_hash.c \
elf_scnshndx.c \
elf32_getchdr.c elf64_getchdr.c gelf_getchdr.c \
elf_compress.c elf_compress_gnu.c
libelf_pic_a_SOURCES =
am_libelf_pic_a_OBJECTS = $(libelf_a_SOURCES:.c=.os)
libelf_so_DEPS = ../lib/libeu.a
libelf_so_LDLIBS = $(libelf_so_DEPS) -lz
if USE_LOCKS
libelf_so_LDLIBS += -lpthread
endif
libelf_so_LIBS = libelf_pic.a
libelf_so_SOURCES =
libelf.so$(EXEEXT): $(srcdir)/libelf.map $(libelf_so_LIBS) $(libelf_so_DEPS)
$(AM_V_CCLD)$(LINK) -shared -o $@ \
-Wl,--soname,$@.$(VERSION),-z,defs,-z,relro \
-Wl,--version-script,$<,--no-undefined \
-Wl,--whole-archive $(libelf_so_LIBS) -Wl,--no-whole-archive \
$(libelf_so_LDLIBS)
@$(textrel_check)
$(AM_V_at)ln -fs $@ $@.$(VERSION)
install: install-am libelf.so
$(mkinstalldirs) $(DESTDIR)$(libdir)
$(INSTALL_PROGRAM) libelf.so $(DESTDIR)$(libdir)/libelf-$(PACKAGE_VERSION).so
ln -fs libelf-$(PACKAGE_VERSION).so $(DESTDIR)$(libdir)/libelf.so.$(VERSION)
ln -fs libelf.so.$(VERSION) $(DESTDIR)$(libdir)/libelf.so
uninstall: uninstall-am
rm -f $(DESTDIR)$(libdir)/libelf-$(PACKAGE_VERSION).so
rm -f $(DESTDIR)$(libdir)/libelf.so.$(VERSION)
rm -f $(DESTDIR)$(libdir)/libelf.so
noinst_HEADERS = elf.h abstract.h common.h exttypes.h gelf_xlate.h libelfP.h \
version_xlate.h gnuhash_xlate.h note_xlate.h dl-hash.h \
chdr_xlate.h
EXTRA_DIST = libelf.map
CLEANFILES += $(am_libelf_pic_a_OBJECTS) libelf.so.$(VERSION)

File diff suppressed because it is too large Load Diff

View File

@ -1,150 +0,0 @@
ELFUTILS_1.0 {
global:
elf32_checksum;
elf32_fsize;
elf32_getehdr;
elf32_getphdr;
elf32_getshdr;
elf32_newehdr;
elf32_newphdr;
elf32_xlatetof;
elf32_xlatetom;
elf64_checksum;
elf64_fsize;
elf64_getehdr;
elf64_getphdr;
elf64_getshdr;
elf64_newehdr;
elf64_newphdr;
elf64_xlatetof;
elf64_xlatetom;
elf_begin;
elf_clone;
elf_cntl;
elf_end;
elf_errmsg;
elf_errno;
elf_fill;
elf_flagdata;
elf_flagehdr;
elf_flagelf;
elf_flagphdr;
elf_flagscn;
elf_flagshdr;
elf_getarhdr;
elf_getarsym;
elf_getbase;
elf_getdata;
elf_getident;
elf_getscn;
elf_getshnum;
elf_getshstrndx;
elf_hash;
elf_kind;
elf_memory;
elf_ndxscn;
elf_newdata;
elf_newscn;
elf_next;
elf_nextscn;
elf_rand;
elf_rawdata;
elf_rawfile;
elf_scncnt;
elf_strptr;
elf_update;
elf_version;
gelf_checksum;
gelf_fsize;
gelf_getclass;
gelf_getdyn;
gelf_getehdr;
gelf_getmove;
gelf_getphdr;
gelf_getrel;
gelf_getrela;
gelf_getshdr;
gelf_getsym;
gelf_getsyminfo;
gelf_getsymshndx;
gelf_getverdaux;
gelf_getverdef;
gelf_getvernaux;
gelf_getverneed;
gelf_getversym;
gelf_newehdr;
gelf_newphdr;
gelf_update_dyn;
gelf_update_ehdr;
gelf_update_move;
gelf_update_phdr;
gelf_update_rel;
gelf_update_rela;
gelf_update_shdr;
gelf_update_sym;
gelf_update_syminfo;
gelf_update_symshndx;
gelf_update_verdaux;
gelf_update_verdef;
gelf_update_vernaux;
gelf_update_verneed;
gelf_update_versym;
gelf_xlatetof;
gelf_xlatetom;
nlist;
local:
*;
};
ELFUTILS_1.1 {
global:
gelf_getlib;
gelf_update_lib;
} ELFUTILS_1.0;
ELFUTILS_1.1.1 {
global:
elf32_offscn;
elf64_offscn;
gelf_offscn;
elf_getaroff;
} ELFUTILS_1.1;
ELFUTILS_1.2 {
global:
elf_gnu_hash;
} ELFUTILS_1.1.1;
ELFUTILS_1.3 {
global:
elf_getdata_rawchunk;
gelf_getauxv;
gelf_update_auxv;
gelf_getnote;
} ELFUTILS_1.2;
ELFUTILS_1.4 {
global:
elf_scnshndx;
} ELFUTILS_1.3;
ELFUTILS_1.5 {
global:
elf_getshdrnum; elf_getshdrstrndx;
} ELFUTILS_1.4;
ELFUTILS_1.6 {
global:
elf_getphdrnum;
} ELFUTILS_1.5;
ELFUTILS_1.7 {
global:
elf32_getchdr;
elf64_getchdr;
gelf_getchdr;
elf_compress;
elf_compress_gnu;
} ELFUTILS_1.6;

View File

@ -1,35 +0,0 @@
/* Copyright (C) 2002 Red Hat, Inc.
This file is part of elfutils.
This file is free software; you can redistribute it and/or modify
it under the terms of either
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at
your option) any later version
or
* 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
or both in parallel, as here.
elfutils 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 copies of the GNU General Public License and
the GNU Lesser General Public License along with this program. If
not, see <http://www.gnu.org/licenses/>. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#define crc32 attribute_hidden __libelf_crc32
#define LIB_SYSTEM_H 1
#include <libelf.h>
#include "../lib/crc32.c"

View File

@ -1,33 +0,0 @@
/* Copyright (C) 2002 Red Hat, Inc.
This file is part of elfutils.
This file is free software; you can redistribute it and/or modify
it under the terms of either
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at
your option) any later version
or
* 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
or both in parallel, as here.
elfutils 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 copies of the GNU General Public License and
the GNU Lesser General Public License along with this program. If
not, see <http://www.gnu.org/licenses/>. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#define next_prime attribute_hidden __libelf_next_prime
#include "../lib/next_prime.c"

7
libelf/CMakeLists.txt Normal file
View File

@ -0,0 +1,7 @@
file(GLOB ELF_FILES src/*.c src/*.h include/*.h)
add_library(ELF ${ELF_FILES}
)
target_include_directories(ELF PRIVATE src)
target_include_directories(ELF PUBLIC include)
target_link_libraries(ELF -lz)
target_compile_definitions(ELF PRIVATE HAVE_CONFIG_H)

View File

@ -1,3 +1,8 @@
2017-09-27 Wolfgang Thaller <wolfgang.thaller@gmx.net>
Gut the whole thing and keep just libelf, with a very simple
CMakeLists.txt for building. That's all I need :-).
2017-07-19 Gustavo Romero <gromero@linux.vnet.ibm.com>
* elf.h: Add known type in notes segment descriptor for HTM SPRs.

95
libelf/NOTES Normal file
View File

@ -0,0 +1,95 @@
Fundamental design decision:
- the sizes of external and internal types are assumed to be the same.
This leaves byte ordering aside. While assuming this the code can be
greatly simplified and speed increases. Since no change violating this
assumption is in sight this is believed to be a worthwhile optimization.
- the ABI of the backend modules is not guaranteed. Really, no guarantee
whatsoever. We are enforcing this in the code. The modules and their
users must match. No third-party EBL module are supported or allowed.
The only reason there are separate modules is to not have the code for
all architectures in all the binaries.
- although the public libraries (libasm, libdw) have a stable API and are
backwards ABI compatible they, and the elfutils tools, do depend on each
others internals, and on internals of libelf to provide their interfaces.
So they should always be upgraded in lockstep when packaging the tools
and libraries separately. For one example of how to do that, see the
config/elfutils.spec.
Some notes:
- old GNU ld's behavior wrt DSOs seems to be severely broken.
y.o reference foo()
y1.o defines foo(), references bar()
y2.o defines bar()
libbar.so defines bar()
Running
gcc -o y y.o -lbar y1.o y2.o
uses the bar() definition from libbar.so and does not mention the definition
in y2.o at all (no duplicate symbol message). Correct is to use the
definition in y2.o.
y.o reference foo()
y1.o defines foo(), references bar()
y2.o in liby2.a defines bar()
libbar.so defines bar()
Running
gcc -o y y.o -lbar y1.o -ly3
has to use the definition in -lbar and not pull the definition from liby3.a.
- the old linker follows DT_NEEDED entries and adds the objects referenced
this way which define a symbol which is needed as a DT_NEEDED to the
generated binary. This is wrong since the DT_NEEDED changes the search
path in the object (which is breadth first).
- the old linker supported extern "C++", extern "java" in version scripts.
I believe this implementation is severly broken and needs a redesign
(how do wildcards work with these languages*?). Therefore it is left
out for now.
- what should happen if two sections in different files with the same
name have different types and/or the flags are different
- section names in input files are mostly irrelevant. Exceptions:
.comment/SHT_PROGBITS in strip, ld
.debug \
.line |
.debug_srcinfo |
.debug_sfnames |
.debug_aranges |
.debug_pubnames |
.debug_info |
.debug_abbrev |
.debug_line |
.debug_abbrev > DWARF sections in ld
.debug_line |
.debug_frame |
.debug_str |
.debug_loc |
.debug_macinfo |
.debug_weaknames |
.debug_funcnames |
.debug_typenames |
.debug_varnames /
Sections created in output files follow the naming of special section
from the gABI.
In no place is a section solely indentified by its name. Internal
references always use the section index.

View File

@ -1,3 +1,5 @@
This directory contains a subset of elfutils, ripped out from the rest for use in Retro68.
The elfutils project provides libraries and tools for ELF files and DWARF data.
The project home is http://elfutils.org/

6
libelf/THANKS Normal file
View File

@ -0,0 +1,6 @@
At least the following have submitted valuable patches:
Jeff Johnson building. rpm wrestling
Alexander Larsson separate debug info
Jakub Jelinek bug fixes, testing
Denys Vlasenko bug fuxes

View File

@ -41,7 +41,7 @@
/* The error number. */
static __thread int global_error;
static /* __thread */ int global_error;
int

Some files were not shown because too many files have changed in this diff Show More