우분투 20.04 elfutils patch

우분투 20.04에서 elfuilts를 빌드하면 아래와 같은 에러가 발생한다.

| gcc  -D_GNU_SOURCE -DHAVE_CONFIG_H -DLOCALEDIR='"/media/gon/proj/RDK/temp/build-raspberrypi-rdk-hybrid/tmp/sysroots/x86_64-linux/usr/share/locale"' -I. -I../../elfutils-0.166/libelf -I..  -I. -I../../elfutils-0.166/libelf -I../../elfutils-0.166/lib -I.. -isystem/media/gon/proj/RDK/temp/build-raspberrypi-rdk-hybrid/tmp/sysroots/x86_64-linux/usr/include -std=gnu99 -Wall -Wshadow -Wformat=2 -Wold-style-definition -Wstrict-prototypes -Wlogical-op -Wduplicated-cond -Wnull-dereference -Wimplicit-fallthrough -Werror -Wunused -Wextra -Wstack-usage=262144   -isystem/media/gon/proj/RDK/temp/build-raspberrypi-rdk-hybrid/tmp/sysroots/x86_64-linux/usr/include -O2 -pipe -c -o elf64_xlatetof.o ../../elfutils-0.166/libelf/elf64_xlatetof.c
| cc1: all warnings being treated as errors
| make[2]: *** [Makefile:709: elf32_fsize.o] Error 1
| make[2]: *** Waiting for unfinished jobs....
| In file included from ../config.h:112,
|                  from ../../elfutils-0.166/libelf/elf32_fsize.c:31,
|                  from ../../elfutils-0.166/libelf/elf64_fsize.c:31:
| ../../elfutils-0.166/libelf/libelfP.h:51:30: error: ‘__elf64_msize’ specifies less restrictive attribute than its target ‘elf64_fsize’: ‘const’ [-Werror=missing-attributes]
|    51 | #define __elfw2_(Bits, Name) __elf##Bits##_##Name
|       |                              ^~~~~
| ../../elfutils-0.166/lib/eu-config.h:60:26: note: in definition of macro ‘strong_alias’
|    60 |   extern __typeof (name) aliasname __attribute__ ((alias (#name)));
|       |                          ^~~~~~~~~
| ../../elfutils-0.166/libelf/elf32_fsize.c:68:1: note: in expansion of macro ‘local_strong_alias’
|    68 | local_strong_alias (elfw2(LIBELFBITS, fsize), __elfw2(LIBELFBITS, msize))
|       | ^~~~~~~~~~~~~~~~~~
| ../../elfutils-0.166/libelf/libelfP.h:56:29: note: in expansion of macro ‘__elfw2_’
|    56 | #define __elfw2(Bits, Name) __elfw2_(Bits, Name)
|       |                             ^~~~~~~~
| ../../elfutils-0.166/libelf/elf32_fsize.c:68:47: note: in expansion of macro ‘__elfw2’
|    68 | local_strong_alias (elfw2(LIBELFBITS, fsize), __elfw2(LIBELFBITS, msize))
|       |                                               ^~~~~~~
| In file included from ../../elfutils-0.166/libelf/elf32_fsize.c:35,
|                  from ../../elfutils-0.166/libelf/elf64_fsize.c:31:
| ../../elfutils-0.166/libelf/libelfP.h:52:28: note: ‘__elf64_msize’ target declared here
|    52 | #define elfw2_(Bits, Name) elf##Bits##_##Name
|       |                            ^~~
| ../../elfutils-0.166/libelf/libelfP.h:57:27: note: in expansion of macro ‘elfw2_’
|    57 | #define elfw2(Bits, Name) elfw2_(Bits, Name)
|       |                           ^~~~~~
| ../../elfutils-0.166/libelf/elf32_fsize.c:43:1: note: in expansion of macro ‘elfw2’
|    43 | elfw2(LIBELFBITS, fsize) (Elf_Type type, size_t count, unsigned int version)
|       | ^~~~~
| cc1: all warnings being treated as errors
| make[2]: *** [Makefile:709: elf64_fsize.o] Error 1
| make[1]: *** [Makefile:479: all-recursive] Error 1
| make: *** [Makefile:395: all] Error 2

위 에러는 git에서 patch 된 것을 확인할 수 있으며, 아래의 패치 사항을 적용하면 빌드 오류를 수정할 수 있다.

Those functions were intended for ELF versions where the memory and file sizes of data structures are different. They were never used because libelf depends on the file and memory sizes being equal (otherwise using mmap wouldn't work).
diff -Nura elfutils-0.166_old/libelf/elf32_fsize.c elfutils-0.166_new/libelf/elf32_fsize.c
--- elfutils-0.166_old/libelf/elf32_fsize.c	2015-11-27 22:36:29.000000000 +0900
+++ elfutils-0.166_new/libelf/elf32_fsize.c	2020-10-30 17:53:45.242120494 +0900
@@ -64,5 +64,3 @@
 	  * __libelf_type_sizes[0][ELFW(ELFCLASS,LIBELFBITS) - 1][type]);
 #endif
 }
-#define local_strong_alias(n1, n2) strong_alias (n1, n2)
-local_strong_alias (elfw2(LIBELFBITS, fsize), __elfw2(LIBELFBITS, msize))
diff -Nura elfutils-0.166_old/libelf/libelfP.h elfutils-0.166_new/libelf/libelfP.h
--- elfutils-0.166_old/libelf/libelfP.h	2016-01-12 21:49:19.000000000 +0900
+++ elfutils-0.166_new/libelf/libelfP.h	2020-10-30 17:54:53.562810387 +0900
@@ -455,16 +455,6 @@
    be ELF_T_BYTE.  */
 extern Elf_Type __libelf_data_type (Elf *elf, int sh_type) internal_function;
 
-/* The libelf API does not have such a function but it is still useful.
-   Get the memory size for the given type.
-
-   These functions cannot be marked internal since they are aliases
-   of the export elfXX_fsize functions.*/
-extern size_t __elf32_msize (Elf_Type __type, size_t __count,
-			     unsigned int __version);
-extern size_t __elf64_msize (Elf_Type __type, size_t __count,
-			     unsigned int __version);
-
 
 /* Create Elf descriptor from memory image.  */
 extern Elf *__libelf_read_mmaped_file (int fildes, void *map_address,