summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimm Bäder <tbaeder@redhat.com>2021-02-17 09:45:07 +0100
committerMark Wielaard <mark@klomp.org>2021-03-01 23:00:57 +0100
commitc9ccf7e3f0a98afea1ca54857f6d2042611853b9 (patch)
tree5ad95bd72d43d4cd20e60bca8e8571671db1b54d
parentd1cbce88d7e4c7f9c183da79d92d9b6183e0c343 (diff)
downloadelfutils-c9ccf7e3f0a98afea1ca54857f6d2042611853b9.tar.gz
elfcompress: Pull set_section() into file scope
Get rid of a nested function this way. Signed-off-by: Timm Bäder <tbaeder@redhat.com>
-rw-r--r--src/ChangeLog6
-rw-r--r--src/elfcompress.c16
2 files changed, 15 insertions, 7 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 833d05e4..0740807c 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,11 @@
2021-02-17 Timm Bäder <tbaeder@redhat.com>
+ * elfcompress.c (process_file): Move set_section function...
+ (set_section): ...to top-level static function taking a
+ section array.
+
+2021-02-17 Timm Bäder <tbaeder@redhat.com>
+
* unstrip.c (handle_implicit_modules): Inline the next function
in three places. This is simply dwfl_getmodules with match_module
callback providing mmi.
diff --git a/src/elfcompress.c b/src/elfcompress.c
index 1b5b1e36..65a922a7 100644
--- a/src/elfcompress.c
+++ b/src/elfcompress.c
@@ -52,6 +52,8 @@ static const char *foutput = NULL;
#define T_DECOMPRESS 1 /* none */
#define T_COMPRESS_ZLIB 2 /* zlib */
#define T_COMPRESS_GNU 3 /* zlib-gnu */
+#define WORD_BITS (8U * sizeof (unsigned int))
+
static int type = T_UNSET;
struct section_pattern
@@ -242,6 +244,12 @@ compress_section (Elf_Scn *scn, size_t orig_size, const char *name,
return res;
}
+static void
+set_section (unsigned int *sections, size_t ndx)
+{
+ sections[ndx / WORD_BITS] |= (1U << (ndx % WORD_BITS));
+}
+
static int
process_file (const char *fname)
{
@@ -275,12 +283,6 @@ process_file (const char *fname)
/* How many sections are we talking about? */
size_t shnum = 0;
-#define WORD_BITS (8U * sizeof (unsigned int))
- void set_section (size_t ndx)
- {
- sections[ndx / WORD_BITS] |= (1U << (ndx % WORD_BITS));
- }
-
bool get_section (size_t ndx)
{
return (sections[ndx / WORD_BITS] & (1U << (ndx % WORD_BITS))) != 0;
@@ -498,7 +500,7 @@ process_file (const char *fname)
else if (shdr->sh_type != SHT_NOBITS
&& (shdr->sh_flags & SHF_ALLOC) == 0)
{
- set_section (ndx);
+ set_section (sections, ndx);
/* Check if we might want to change this section name. */
if (! adjust_names
&& ((type != T_COMPRESS_GNU