elftoolchain

This commit is contained in:
cowmonk 2025-11-15 13:08:46 -07:00
parent 58d098dfae
commit a9a3077633
16 changed files with 260 additions and 14 deletions

View file

@ -0,0 +1,25 @@
From b287a2c2b779758a31dc3902a7daf63cc0e6727f Mon Sep 17 00:00:00 2001
From: Daniel Kolesa <daniel@octaforge.org>
Date: Wed, 23 Jun 2021 01:40:50 +0200
Subject: [PATCH 1/2] disable ld build
---
Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index e8713982..cbfd9c59 100644
--- a/Makefile
+++ b/Makefile
@@ -31,7 +31,7 @@ SUBDIR += cxxfilt
SUBDIR += elfcopy
SUBDIR += elfdump
SUBDIR += findtextrel
-SUBDIR += ld
+#SUBDIR += ld
SUBDIR += nm
SUBDIR += readelf
SUBDIR += size
--
2.32.0

View file

@ -0,0 +1,26 @@
From fe335f0f01aabe08df740092306ecc107ff5d96d Mon Sep 17 00:00:00 2001
From: Michael Forney <mforney@mforney.org>
Date: Mon, 28 Jun 2021 18:23:22 -0700
Subject: [PATCH] Allow empty Elf_Data
---
libelf/elf_update.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/libelf/elf_update.c b/libelf/elf_update.c
index 3e19b78a..62f64fc1 100644
--- a/libelf/elf_update.c
+++ b/libelf/elf_update.c
@@ -815,6 +815,9 @@ _libelf_write_scn(Elf *e, unsigned char *nf, struct _Elf_Extent *ex)
LIBELF_PRIVATE(fillchar),
(size_t) (sh_off + d->d_off - (uint64_t) rc));
+ if (d->d_size == 0)
+ continue;
+
rc = (off_t) (sh_off + d->d_off);
assert(d->d_buf != NULL);
--
2.32.0

View file

@ -0,0 +1,14 @@
Using --as-needed here eliminates the libelf linkage,
which results in undefined symbols at runtime.
--- a/cxxfilt/Makefile
+++ b/cxxfilt/Makefile
@@ -8,7 +8,7 @@ SRCS= cxxfilt.c
WARNS?= 6
DPADD= ${LIBELFTC} ${LIBELF}
-LDADD= -lelftc -lelf
+LDADD= -Wl,--no-as-needed -lelftc -lelf
MAN1= c++filt.1

View file

@ -0,0 +1,11 @@
--- elftoolchain-f27fcce314b91b3dece6bee90949183f7a1e18b3/libelftc/make-toolchain-version 2022-05-06 06:22:42.000000000 -0500
+++ elftoolchain-0.7.1/libelftc/make-toolchain-version 2023-10-07 19:26:54.758190500 -0500
@@ -42,7 +42,7 @@
# - Otherwise, we use `git --describe'.
get_revision_string()
{
- v="unknown:unknown"
+ v="0.7.1:svn-20230416"
if [ -d CVS ]; then # Look for CVS (NetBSD).
v="cvs:unknown"
elif [ -d .svn ]; then # An SVN checkout (SourceForge or FreeBSD).

View file

@ -0,0 +1,39 @@
From 974e9f2d745c4c20a6f68b54e7f9c1d38078434c Mon Sep 17 00:00:00 2001
From: Daniel Kolesa <daniel@octaforge.org>
Date: Fri, 5 Nov 2021 22:21:54 +0100
Subject: [PATCH] use symlinks for binaries
---
ar/Makefile | 2 +-
elfcopy/Makefile | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/ar/Makefile b/ar/Makefile
index cfbaac3..ae49132 100644
--- a/ar/Makefile
+++ b/ar/Makefile
@@ -14,7 +14,7 @@ LDADD= -larchive -lelftc -lelf -lz
CFLAGS+=-I. -I${.CURDIR}
-LINKS= ${BINDIR}/ar ${BINDIR}/ranlib
+SYMLINKS= ${BINDIR}/ar ${BINDIR}/ranlib
EXTRA_TARGETS= ranlib
diff --git a/elfcopy/Makefile b/elfcopy/Makefile
index a73515a..ca6e03c 100644
--- a/elfcopy/Makefile
+++ b/elfcopy/Makefile
@@ -31,7 +31,7 @@ MLINKS= elfcopy.1 objcopy.1
NO_SHARED?= yes
-LINKS= ${BINDIR}/elfcopy ${BINDIR}/mcs \
+SYMLINKS= ${BINDIR}/elfcopy ${BINDIR}/mcs \
${BINDIR}/elfcopy ${BINDIR}/objcopy \
${BINDIR}/elfcopy ${BINDIR}/strip
--
2.33.1