]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
elflint: fix undefined 'buffer_left' reference
authorSergei Trofimovich <slyfox@gentoo.org>
Mon, 7 Jun 2021 21:37:42 +0000 (22:37 +0100)
committerDmitry V. Levin <ldv@altlinux.org>
Mon, 7 Jun 2021 22:02:41 +0000 (22:02 +0000)
Link failure is reproducible on gcc-11.1.0 target:

```
$ autoreconf -i -f
$ ./configure --enable-maintainer-mode --disable-debuginfod \
    --host=x86_64-pc-linux-gnu \
    CFLAGS=-march=znver3 \
    CXXFLAGS=-march=znver3 \
    LDFLAGS=" "
$ make

  CCLD     elflint
ld: elflint.o: in function `check_attributes':
elflint.c:(.text+0xdcff): undefined reference to `buffer_left'
ld: elflint.c:(.text+0xe557): undefined reference to `buffer_left'
```

It happens due to possible external linkage of `buffer_left()`.

The change forces local linkage to always use local definition
(either inline or out-of-line).

Reported-by: Toralf Förster
Bug: https://bugs.gentoo.org/794601
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Fixes: e95d1fbb ("elflint: Pull left() in file scope")
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
src/ChangeLog
src/elflint.c

index 2c7be185ba116c495270583618106b18756135ed..698b3c77c8d0ebebc18ed9751a1cb3f251db9336 100644 (file)
@@ -1,3 +1,8 @@
+2021-06-06  Sergei Trofimovich  <slyfox@gentoo.org>
+
+       * elflint.c (buffer_left): Mark as 'static' to avoid external linkage
+       failure.
+
 2021-05-12  Dmitry V. Levin  <ldv@altlinux.org>
 
        * elfcompress.c (process_file): Return 1 instead of -1 in case of an
index 85cc7833d3c7011e0c7d1514f79615f18f777e06..35b405003be7a32bc8287fe37d311bf9e3ad2f7a 100644 (file)
@@ -3434,7 +3434,7 @@ buffer_pos (Elf_Data *data, const unsigned char *p)
   return p - (const unsigned char *) data->d_buf;
 }
 
-inline size_t
+static inline size_t
 buffer_left (Elf_Data *data, const unsigned char *p)
 {
   return (const unsigned char *) data->d_buf + data->d_size - p;