summaryrefslogtreecommitdiff
path: root/pkg/elftoolchain/patch/0005-Allow-empty-Elf_Data.patch
blob: f1aff7a216e94f06824692f9112ee82f4cadb949 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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