public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/7] Enable building libelf of elfutils on win32
@ 2022-09-20  8:43 Yonggang Luo
  2022-09-20  8:43 ` [PATCH 1/7] Rename 'hello2.spec.' -> 'hello2.spec' 'hello3.spec.' -> 'hello3.spec' Yonggang Luo
                   ` (6 more replies)
  0 siblings, 7 replies; 26+ messages in thread
From: Yonggang Luo @ 2022-09-20  8:43 UTC (permalink / raw)
  To: elfutils-devel; +Cc: Yonggang Luo

After these changes, now libelf can be build with mingw/gcc and msvc/clang

Yonggang Luo (7):
  Rename 'hello2.spec.' -> 'hello2.spec' 'hello3.spec.' -> 'hello3.spec'
  move platform depended include into system.h
  lib: Use NOT_HAVE_LIBINTL to guard if need #include <libintl.h>
  Remove duplicated #include <libintl.h>
  Strip __ prefix from __BYTE_ORDER __LITTLE_ENDIAN and __BIG_ENDIAN
  Fixes building with msvc/clang mingw/gcc
  Add CMake build files

 .gitignore                                    |   1 +
 CMakeLists.txt                                |  47 +++++
 configure.ac                                  |   1 +
 debuginfod/debuginfod.cxx                     |   1 -
 lib/color.c                                   |   1 -
 lib/eu-config.h                               |   8 +
 lib/printversion.c                            |   1 -
 lib/system.h                                  |  74 ++++++-
 lib/system_win32.c                            | 162 +++++++++++++++
 lib/xasprintf.c                               |   1 -
 lib/xmalloc.c                                 |   1 -
 libasm/asm_end.c                              |   1 -
 libasm/asm_error.c                            |   1 -
 libasm/asm_newscn.c                           |   1 -
 libcpu/i386_disasm.c                          |   2 +-
 libcpu/i386_lex.l                             |   1 -
 libcpu/i386_parse.y                           |   1 -
 libcpu/memory-access.h                        |  26 +--
 libcpu/riscv_disasm.c                         |   2 +-
 libdw/libdwP.h                                |   1 -
 libdw/memory-access.h                         |   8 +-
 libdwfl/argp-std.c                            |   1 -
 libdwfl/dwfl_error.c                          |   1 -
 libdwfl/dwfl_segment_report_module.c          |   2 +-
 libebl/eblmachineflagname.c                   |   1 -
 libebl/eblobjnotetypename.c                   |   2 -
 libebl/eblopenbackend.c                       |   1 -
 libebl/libeblP.h                              |   1 -
 libelf/CMakeLists.txt                         | 192 ++++++++++++++++++
 libelf/common.h                               |   5 +-
 libelf/config-cmake/config.h                  |  27 +++
 libelf/elf32_checksum.c                       |   5 +-
 libelf/elf32_getphdr.c                        |   2 -
 libelf/elf32_getshdr.c                        |   2 -
 libelf/elf32_updatefile.c                     |   6 +-
 libelf/elf32_updatenull.c                     |   2 -
 libelf/elf32_xlatetof.c                       |   5 +-
 libelf/elf32_xlatetom.c                       |   1 -
 libelf/elf_begin.c                            |  10 +-
 libelf/elf_cntl.c                             |   2 -
 libelf/elf_compress.c                         |   2 -
 libelf/elf_end.c                              |   3 +-
 libelf/elf_error.c                            |   1 -
 libelf/elf_getarsym.c                         |  10 +-
 libelf/elf_getdata.c                          |   2 -
 libelf/elf_getdata_rawchunk.c                 |   2 -
 libelf/elf_getshdrstrndx.c                    |   2 -
 libelf/elf_readall.c                          |   2 -
 libelf/elf_update.c                           |   7 +-
 libelf/gelf_xlate.c                           |   1 -
 libelf/libelf.h                               |   6 +
 libelf/libelfP.h                              |   5 +
 libelf/nlist.c                                |   1 -
 lib/xasprintf.c => libelf/win32/ar.h          | 104 +++++-----
 src/addr2line.c                               |   1 -
 src/ar.c                                      |   1 -
 src/arlib-argp.c                              |   1 -
 src/arlib.c                                   |   1 -
 src/arlib.h                                   |   2 +-
 src/arlib2.c                                  |   1 -
 src/elfcmp.c                                  |   1 -
 src/elflint.c                                 |   1 -
 src/findtextrel.c                             |   1 -
 src/nm.c                                      |   1 -
 src/objdump.c                                 |   1 -
 src/ranlib.c                                  |   1 -
 src/readelf.c                                 |   1 -
 src/size.c                                    |   1 -
 src/strings.c                                 |   1 -
 src/strip.c                                   |   1 -
 src/unstrip.c                                 |   1 -
 tests/Makefile.am                             |   2 +-
 .../{hello2.spec. => hello2.spec}             |   0
 .../{hello3.spec. => hello3.spec}             |   0
 74 files changed, 612 insertions(+), 166 deletions(-)
 create mode 100644 CMakeLists.txt
 create mode 100644 lib/system_win32.c
 create mode 100644 libelf/CMakeLists.txt
 create mode 100644 libelf/config-cmake/config.h
 copy lib/xasprintf.c => libelf/win32/ar.h (66%)
 rename tests/debuginfod-rpms/{hello2.spec. => hello2.spec} (100%)
 rename tests/debuginfod-rpms/{hello3.spec. => hello3.spec} (100%)

-- 
2.36.1.windows.1


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH 1/7] Rename 'hello2.spec.' -> 'hello2.spec' 'hello3.spec.' -> 'hello3.spec'
  2022-09-20  8:43 [PATCH 0/7] Enable building libelf of elfutils on win32 Yonggang Luo
@ 2022-09-20  8:43 ` Yonggang Luo
  2022-10-14 20:35   ` Mark Wielaard
  2022-09-20  8:43 ` [PATCH 2/7] move platform depended include into system.h Yonggang Luo
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 26+ messages in thread
From: Yonggang Luo @ 2022-09-20  8:43 UTC (permalink / raw)
  To: elfutils-devel; +Cc: Yonggang Luo

These filenames are invalid on win32

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
 tests/Makefile.am                                   | 2 +-
 tests/debuginfod-rpms/{hello2.spec. => hello2.spec} | 0
 tests/debuginfod-rpms/{hello3.spec. => hello3.spec} | 0
 3 files changed, 1 insertion(+), 1 deletion(-)
 rename tests/debuginfod-rpms/{hello2.spec. => hello2.spec} (100%)
 rename tests/debuginfod-rpms/{hello3.spec. => hello3.spec} (100%)

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 85514898..fc2235f4 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -563,7 +563,7 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh run-ar.sh \
 	     debuginfod-rpms/fedora31/hello3-debugsource-1.0-2.x86_64.rpm \
 	     debuginfod-rpms/fedora31/hello3-two-1.0-2.x86_64.rpm \
 	     debuginfod-rpms/fedora31/hello3-two-debuginfo-1.0-2.x86_64.rpm \
-	     debuginfod-rpms/hello2.spec. \
+	     debuginfod-rpms/hello2.spec \
 	     debuginfod-rpms/rhel6/hello2-1.0-2.i686.rpm \
 	     debuginfod-rpms/rhel6/hello2-1.0-2.src.rpm \
 	     debuginfod-rpms/rhel6/hello2-debuginfo-1.0-2.i686.rpm \
diff --git a/tests/debuginfod-rpms/hello2.spec. b/tests/debuginfod-rpms/hello2.spec
similarity index 100%
rename from tests/debuginfod-rpms/hello2.spec.
rename to tests/debuginfod-rpms/hello2.spec
diff --git a/tests/debuginfod-rpms/hello3.spec. b/tests/debuginfod-rpms/hello3.spec
similarity index 100%
rename from tests/debuginfod-rpms/hello3.spec.
rename to tests/debuginfod-rpms/hello3.spec
-- 
2.36.1.windows.1


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH 2/7] move platform depended include into system.h
  2022-09-20  8:43 [PATCH 0/7] Enable building libelf of elfutils on win32 Yonggang Luo
  2022-09-20  8:43 ` [PATCH 1/7] Rename 'hello2.spec.' -> 'hello2.spec' 'hello3.spec.' -> 'hello3.spec' Yonggang Luo
@ 2022-09-20  8:43 ` Yonggang Luo
  2022-10-14 21:16   ` Mark Wielaard
  2022-09-20  8:43 ` [PATCH 3/7] lib: Use NOT_HAVE_LIBINTL to guard if need #include <libintl.h> Yonggang Luo
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 26+ messages in thread
From: Yonggang Luo @ 2022-09-20  8:43 UTC (permalink / raw)
  To: elfutils-devel; +Cc: Yonggang Luo

All of these files either #include <system.h> directly or #include "libelfP.h"
And now "libelfP.h also #include <system.h>, so the platform depended include
can be moved to system.h safely

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
 lib/system.h                  | 11 +++++++----
 libebl/eblmachineflagname.c   |  1 -
 libebl/eblobjnotetypename.c   |  2 --
 libebl/eblopenbackend.c       |  1 -
 libelf/common.h               |  3 ---
 libelf/elf32_checksum.c       |  1 -
 libelf/elf32_getphdr.c        |  2 --
 libelf/elf32_getshdr.c        |  2 --
 libelf/elf32_updatefile.c     |  3 ---
 libelf/elf32_updatenull.c     |  2 --
 libelf/elf32_xlatetof.c       |  1 -
 libelf/elf32_xlatetom.c       |  1 -
 libelf/elf_begin.c            |  3 ---
 libelf/elf_cntl.c             |  2 --
 libelf/elf_compress.c         |  2 --
 libelf/elf_end.c              |  1 -
 libelf/elf_error.c            |  1 -
 libelf/elf_getarsym.c         |  4 ----
 libelf/elf_getdata.c          |  2 --
 libelf/elf_getdata_rawchunk.c |  2 --
 libelf/elf_getshdrstrndx.c    |  2 --
 libelf/elf_readall.c          |  2 --
 libelf/elf_update.c           |  2 --
 libelf/gelf_xlate.c           |  1 -
 libelf/libelfP.h              |  1 +
 libelf/nlist.c                |  1 -
 26 files changed, 8 insertions(+), 48 deletions(-)

diff --git a/lib/system.h b/lib/system.h
index d3f42c91..48004df1 100644
--- a/lib/system.h
+++ b/lib/system.h
@@ -35,14 +35,17 @@
 #include <errno.h>
 #include <stddef.h>
 #include <stdint.h>
-#include <sys/param.h>
-#include <endian.h>
-#include <byteswap.h>
-#include <unistd.h>
 #include <string.h>
 #include <stdarg.h>
 #include <stdlib.h>
 
+/* System dependend headers */
+#include <byteswap.h>
+#include <endian.h>
+#include <sys/mman.h>
+#include <sys/param.h>
+#include <unistd.h>
+
 #if defined(HAVE_ERROR_H)
 #include <error.h>
 #elif defined(HAVE_ERR_H)
diff --git a/libebl/eblmachineflagname.c b/libebl/eblmachineflagname.c
index 02e11c65..5897735f 100644
--- a/libebl/eblmachineflagname.c
+++ b/libebl/eblmachineflagname.c
@@ -33,7 +33,6 @@
 
 #include <stdio.h>
 #include <string.h>
-#include <system.h>
 #include <libeblP.h>
 
 
diff --git a/libebl/eblobjnotetypename.c b/libebl/eblobjnotetypename.c
index 473a1f2f..2ee1b228 100644
--- a/libebl/eblobjnotetypename.c
+++ b/libebl/eblobjnotetypename.c
@@ -31,8 +31,6 @@
 # include <config.h>
 #endif
 
-#include <system.h>
-
 #include <inttypes.h>
 #include <stdio.h>
 #include <string.h>
diff --git a/libebl/eblopenbackend.c b/libebl/eblopenbackend.c
index c6657252..9ba8728b 100644
--- a/libebl/eblopenbackend.c
+++ b/libebl/eblopenbackend.c
@@ -38,7 +38,6 @@
 #include <string.h>
 #include <stdio.h>
 
-#include <system.h>
 #include <libeblP.h>
 
 Ebl *i386_init (Elf *, GElf_Half, Ebl *);
diff --git a/libelf/common.h b/libelf/common.h
index 3718b3fd..4561854f 100644
--- a/libelf/common.h
+++ b/libelf/common.h
@@ -30,9 +30,6 @@
 #ifndef _COMMON_H
 #define _COMMON_H       1
 
-#include <ar.h>
-#include <byteswap.h>
-#include <endian.h>
 #include <stdlib.h>
 #include <string.h>
 
diff --git a/libelf/elf32_checksum.c b/libelf/elf32_checksum.c
index c5f27bbe..521668a7 100644
--- a/libelf/elf32_checksum.c
+++ b/libelf/elf32_checksum.c
@@ -32,7 +32,6 @@
 #endif
 
 #include <assert.h>
-#include <endian.h>
 #include <stdbool.h>
 #include <stddef.h>
 #include <string.h>
diff --git a/libelf/elf32_getphdr.c b/libelf/elf32_getphdr.c
index 99b4ac09..4bfca24b 100644
--- a/libelf/elf32_getphdr.c
+++ b/libelf/elf32_getphdr.c
@@ -34,10 +34,8 @@
 #include <errno.h>
 #include <stdbool.h>
 #include <stdlib.h>
-#include <unistd.h>
 #include <assert.h>
 
-#include <system.h>
 #include "libelfP.h"
 #include "common.h"
 
diff --git a/libelf/elf32_getshdr.c b/libelf/elf32_getshdr.c
index 237d9122..fc696302 100644
--- a/libelf/elf32_getshdr.c
+++ b/libelf/elf32_getshdr.c
@@ -34,9 +34,7 @@
 #include <assert.h>
 #include <errno.h>
 #include <stdbool.h>
-#include <unistd.h>
 
-#include <system.h>
 #include "libelfP.h"
 #include "common.h"
 
diff --git a/libelf/elf32_updatefile.c b/libelf/elf32_updatefile.c
index 1ff58900..46afa1f4 100644
--- a/libelf/elf32_updatefile.c
+++ b/libelf/elf32_updatefile.c
@@ -37,10 +37,7 @@
 #include <stdbool.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
-#include <sys/mman.h>
 
-#include <system.h>
 #include "libelfP.h"
 
 
diff --git a/libelf/elf32_updatenull.c b/libelf/elf32_updatenull.c
index d0d4d1eb..6c06e5e4 100644
--- a/libelf/elf32_updatenull.c
+++ b/libelf/elf32_updatenull.c
@@ -32,12 +32,10 @@
 #endif
 
 #include <assert.h>
-#include <endian.h>
 #include <libelf.h>
 #include <stdbool.h>
 #include <string.h>
 
-#include <system.h>
 #include "libelfP.h"
 #include "elf-knowledge.h"
 
diff --git a/libelf/elf32_xlatetof.c b/libelf/elf32_xlatetof.c
index 082d833f..377659c8 100644
--- a/libelf/elf32_xlatetof.c
+++ b/libelf/elf32_xlatetof.c
@@ -32,7 +32,6 @@
 #endif
 
 #include <assert.h>
-#include <endian.h>
 #include <string.h>
 
 #include "libelfP.h"
diff --git a/libelf/elf32_xlatetom.c b/libelf/elf32_xlatetom.c
index cb0bb8d5..fa3dc9a7 100644
--- a/libelf/elf32_xlatetom.c
+++ b/libelf/elf32_xlatetom.c
@@ -32,7 +32,6 @@
 #endif
 
 #include <assert.h>
-#include <endian.h>
 #include <string.h>
 
 #include "libelfP.h"
diff --git a/libelf/elf_begin.c b/libelf/elf_begin.c
index 71eb3594..fe8c640a 100644
--- a/libelf/elf_begin.c
+++ b/libelf/elf_begin.c
@@ -39,11 +39,8 @@
 #include <stdbool.h>
 #include <stddef.h>
 #include <string.h>
-#include <unistd.h>
-#include <sys/mman.h>
 #include <sys/stat.h>
 
-#include <system.h>
 #include "libelfP.h"
 #include "common.h"
 
diff --git a/libelf/elf_cntl.c b/libelf/elf_cntl.c
index fd681789..04aa9132 100644
--- a/libelf/elf_cntl.c
+++ b/libelf/elf_cntl.c
@@ -31,8 +31,6 @@
 # include <config.h>
 #endif
 
-#include <unistd.h>
-
 #include "libelfP.h"
 
 
diff --git a/libelf/elf_compress.c b/libelf/elf_compress.c
index df0144e8..d7f53af2 100644
--- a/libelf/elf_compress.c
+++ b/libelf/elf_compress.c
@@ -31,14 +31,12 @@
 #endif
 
 #include <libelf.h>
-#include <system.h>
 #include "libelfP.h"
 #include "common.h"
 
 #include <stddef.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
 #include <zlib.h>
 
 /* Cleanup and return result.  Don't leak memory.  */
diff --git a/libelf/elf_end.c b/libelf/elf_end.c
index 160f0b88..5c451f36 100644
--- a/libelf/elf_end.c
+++ b/libelf/elf_end.c
@@ -34,7 +34,6 @@
 #include <assert.h>
 #include <stddef.h>
 #include <stdlib.h>
-#include <sys/mman.h>
 
 #include "libelfP.h"
 
diff --git a/libelf/elf_error.c b/libelf/elf_error.c
index 5364e685..e596108d 100644
--- a/libelf/elf_error.c
+++ b/libelf/elf_error.c
@@ -32,7 +32,6 @@
 #endif
 
 #include <assert.h>
-#include <libintl.h>
 #include <stdbool.h>
 #include <stdint.h>
 #include <stdlib.h>
diff --git a/libelf/elf_getarsym.c b/libelf/elf_getarsym.c
index 05ebf6a9..2203521f 100644
--- a/libelf/elf_getarsym.c
+++ b/libelf/elf_getarsym.c
@@ -32,16 +32,12 @@
 #endif
 
 #include <assert.h>
-#include <byteswap.h>
-#include <endian.h>
 #include <errno.h>
 #include <stdbool.h>
 #include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
 
-#include <system.h>
 #include <dl-hash.h>
 #include "libelfP.h"
 
diff --git a/libelf/elf_getdata.c b/libelf/elf_getdata.c
index a704aae3..5ebd270f 100644
--- a/libelf/elf_getdata.c
+++ b/libelf/elf_getdata.c
@@ -35,10 +35,8 @@
 #include <errno.h>
 #include <stddef.h>
 #include <string.h>
-#include <unistd.h>
 
 #include "libelfP.h"
-#include <system.h>
 #include "common.h"
 #include "elf-knowledge.h"
 
diff --git a/libelf/elf_getdata_rawchunk.c b/libelf/elf_getdata_rawchunk.c
index 2f55cbb4..5a35ccdc 100644
--- a/libelf/elf_getdata_rawchunk.c
+++ b/libelf/elf_getdata_rawchunk.c
@@ -35,9 +35,7 @@
 #include <errno.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
 
-#include <system.h>
 #include "libelfP.h"
 #include "common.h"
 
diff --git a/libelf/elf_getshdrstrndx.c b/libelf/elf_getshdrstrndx.c
index ad884fd3..2391317b 100644
--- a/libelf/elf_getshdrstrndx.c
+++ b/libelf/elf_getshdrstrndx.c
@@ -35,9 +35,7 @@
 #include <errno.h>
 #include <gelf.h>
 #include <stddef.h>
-#include <unistd.h>
 
-#include <system.h>
 #include "libelfP.h"
 #include "common.h"
 
diff --git a/libelf/elf_readall.c b/libelf/elf_readall.c
index 0a3a233d..d0f9a28c 100644
--- a/libelf/elf_readall.c
+++ b/libelf/elf_readall.c
@@ -32,10 +32,8 @@
 #endif
 
 #include <errno.h>
-#include <unistd.h>
 #include <sys/stat.h>
 
-#include <system.h>
 #include "libelfP.h"
 #include "common.h"
 
diff --git a/libelf/elf_update.c b/libelf/elf_update.c
index 97ca9ca9..56af3a1c 100644
--- a/libelf/elf_update.c
+++ b/libelf/elf_update.c
@@ -33,8 +33,6 @@
 
 #include <libelf.h>
 #include <fcntl.h>
-#include <unistd.h>
-#include <sys/mman.h>
 #include <sys/stat.h>
 
 #include "libelfP.h"
diff --git a/libelf/gelf_xlate.c b/libelf/gelf_xlate.c
index 6f8c57b7..d8ad0634 100644
--- a/libelf/gelf_xlate.c
+++ b/libelf/gelf_xlate.c
@@ -32,7 +32,6 @@
 # include <config.h>
 #endif
 
-#include <byteswap.h>
 #include <stdint.h>
 #include <string.h>
 #include <stdlib.h>
diff --git a/libelf/libelfP.h b/libelf/libelfP.h
index 56331f45..d88a613c 100644
--- a/libelf/libelfP.h
+++ b/libelf/libelfP.h
@@ -39,6 +39,7 @@
 #include <stdio.h>
 #include <string.h>
 
+#include <system.h>
 
 /* Helper Macros to write 32 bit and 64 bit functions.  */
 #define __elfw2_(Bits, Name) __elf##Bits##_##Name
diff --git a/libelf/nlist.c b/libelf/nlist.c
index 8593c1de..b3d60435 100644
--- a/libelf/nlist.c
+++ b/libelf/nlist.c
@@ -35,7 +35,6 @@
 #include <gelf.h>
 #include <libelf.h>
 #include <nlist.h>
-#include <unistd.h>
 
 #include "libelfP.h"
 
-- 
2.36.1.windows.1


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH 3/7] lib: Use NOT_HAVE_LIBINTL to guard if need #include <libintl.h>
  2022-09-20  8:43 [PATCH 0/7] Enable building libelf of elfutils on win32 Yonggang Luo
  2022-09-20  8:43 ` [PATCH 1/7] Rename 'hello2.spec.' -> 'hello2.spec' 'hello3.spec.' -> 'hello3.spec' Yonggang Luo
  2022-09-20  8:43 ` [PATCH 2/7] move platform depended include into system.h Yonggang Luo
@ 2022-09-20  8:43 ` Yonggang Luo
  2022-09-20  8:43 ` [PATCH 4/7] Remove duplicated " Yonggang Luo
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 26+ messages in thread
From: Yonggang Luo @ 2022-09-20  8:43 UTC (permalink / raw)
  To: elfutils-devel; +Cc: Yonggang Luo

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
 lib/eu-config.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/lib/eu-config.h b/lib/eu-config.h
index c7d7cbb2..5e6c3c72 100644
--- a/lib/eu-config.h
+++ b/lib/eu-config.h
@@ -52,9 +52,17 @@
 # define rwlock_unlock(lock) ((void) (lock))
 #endif	/* USE_LOCKS */
 
+#if !defined(NOT_HAVE_LIBINTL)
+#include <libintl.h>
+#endif
+
 /* gettext helper macros.  */
 #define N_(Str) Str
+#if !defined(NOT_HAVE_LIBINTL)
 #define _(Str) dgettext ("elfutils", Str)
+#else
+#define _(Str) N_(Str)
+#endif
 
 /* Compiler-specific definitions.  */
 #define strong_alias(name, aliasname) \
-- 
2.36.1.windows.1


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH 4/7] Remove duplicated #include <libintl.h>
  2022-09-20  8:43 [PATCH 0/7] Enable building libelf of elfutils on win32 Yonggang Luo
                   ` (2 preceding siblings ...)
  2022-09-20  8:43 ` [PATCH 3/7] lib: Use NOT_HAVE_LIBINTL to guard if need #include <libintl.h> Yonggang Luo
@ 2022-09-20  8:43 ` Yonggang Luo
  2022-09-20  8:43 ` [PATCH 5/7] Strip __ prefix from __BYTE_ORDER __LITTLE_ENDIAN and __BIG_ENDIAN Yonggang Luo
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 26+ messages in thread
From: Yonggang Luo @ 2022-09-20  8:43 UTC (permalink / raw)
  To: elfutils-devel; +Cc: Yonggang Luo

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
 debuginfod/debuginfod.cxx | 1 -
 lib/color.c               | 1 -
 lib/printversion.c        | 1 -
 lib/xasprintf.c           | 1 -
 lib/xmalloc.c             | 1 -
 libasm/asm_end.c          | 1 -
 libasm/asm_error.c        | 1 -
 libasm/asm_newscn.c       | 1 -
 libcpu/i386_lex.l         | 1 -
 libcpu/i386_parse.y       | 1 -
 libdw/libdwP.h            | 1 -
 libdwfl/argp-std.c        | 1 -
 libdwfl/dwfl_error.c      | 1 -
 libebl/libeblP.h          | 1 -
 src/addr2line.c           | 1 -
 src/ar.c                  | 1 -
 src/arlib-argp.c          | 1 -
 src/arlib.c               | 1 -
 src/arlib2.c              | 1 -
 src/elfcmp.c              | 1 -
 src/elflint.c             | 1 -
 src/findtextrel.c         | 1 -
 src/nm.c                  | 1 -
 src/objdump.c             | 1 -
 src/ranlib.c              | 1 -
 src/readelf.c             | 1 -
 src/size.c                | 1 -
 src/strings.c             | 1 -
 src/strip.c               | 1 -
 src/unstrip.c             | 1 -
 30 files changed, 30 deletions(-)

diff --git a/debuginfod/debuginfod.cxx b/debuginfod/debuginfod.cxx
index 000a41c4..8e7ee499 100644
--- a/debuginfod/debuginfod.cxx
+++ b/debuginfod/debuginfod.cxx
@@ -47,7 +47,6 @@ extern "C" {
 
 #include <unistd.h>
 #include <stdlib.h>
-#include <libintl.h>
 #include <locale.h>
 #include <pthread.h>
 #include <signal.h>
diff --git a/lib/color.c b/lib/color.c
index e43b6143..bd105ec2 100644
--- a/lib/color.c
+++ b/lib/color.c
@@ -32,7 +32,6 @@
 #endif
 
 #include <argp.h>
-#include <libintl.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
diff --git a/lib/printversion.c b/lib/printversion.c
index f657329c..7d31fa83 100644
--- a/lib/printversion.c
+++ b/lib/printversion.c
@@ -30,7 +30,6 @@
 # include <config.h>
 #endif
 
-#include <libintl.h>
 #include "printversion.h"
 
 void
diff --git a/lib/xasprintf.c b/lib/xasprintf.c
index 179ea2e8..d61fad90 100644
--- a/lib/xasprintf.c
+++ b/lib/xasprintf.c
@@ -33,7 +33,6 @@
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <libintl.h>
 #include "libeu.h"
 #include "system.h"
 
diff --git a/lib/xmalloc.c b/lib/xmalloc.c
index 7c094985..de7211f1 100644
--- a/lib/xmalloc.c
+++ b/lib/xmalloc.c
@@ -30,7 +30,6 @@
 # include <config.h>
 #endif
 
-#include <libintl.h>
 #include <stddef.h>
 #include <stdlib.h>
 #include <sys/types.h>
diff --git a/libasm/asm_end.c b/libasm/asm_end.c
index 077d2aa5..a26120f2 100644
--- a/libasm/asm_end.c
+++ b/libasm/asm_end.c
@@ -32,7 +32,6 @@
 #endif
 
 #include <assert.h>
-#include <libintl.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/libasm/asm_error.c b/libasm/asm_error.c
index cc3e660b..2b769395 100644
--- a/libasm/asm_error.c
+++ b/libasm/asm_error.c
@@ -31,7 +31,6 @@
 # include <config.h>
 #endif
 
-#include <libintl.h>
 #include <stdbool.h>
 #include <stdlib.h>
 
diff --git a/libasm/asm_newscn.c b/libasm/asm_newscn.c
index 1150015f..d258d969 100644
--- a/libasm/asm_newscn.c
+++ b/libasm/asm_newscn.c
@@ -32,7 +32,6 @@
 #endif
 
 #include <assert.h>
-#include <libintl.h>
 #include <stdlib.h>
 #include <string.h>
 
diff --git a/libcpu/i386_lex.l b/libcpu/i386_lex.l
index b6ec0f87..9b33ed95 100644
--- a/libcpu/i386_lex.l
+++ b/libcpu/i386_lex.l
@@ -31,7 +31,6 @@
 #endif
 
 #include <ctype.h>
-#include <libintl.h>
 
 #include <libeu.h>
 #include "system.h"
diff --git a/libcpu/i386_parse.y b/libcpu/i386_parse.y
index 9a92c2e0..d2236d59 100644
--- a/libcpu/i386_parse.y
+++ b/libcpu/i386_parse.y
@@ -35,7 +35,6 @@
 #include <ctype.h>
 #include <errno.h>
 #include <inttypes.h>
-#include <libintl.h>
 #include <math.h>
 #include <obstack.h>
 #include <search.h>
diff --git a/libdw/libdwP.h b/libdw/libdwP.h
index 56b388c1..961fa4e7 100644
--- a/libdw/libdwP.h
+++ b/libdw/libdwP.h
@@ -29,7 +29,6 @@
 #ifndef _LIBDWP_H
 #define _LIBDWP_H 1
 
-#include <libintl.h>
 #include <stdbool.h>
 #include <pthread.h>
 
diff --git a/libdwfl/argp-std.c b/libdwfl/argp-std.c
index 01ec18e2..bc013aa0 100644
--- a/libdwfl/argp-std.c
+++ b/libdwfl/argp-std.c
@@ -34,7 +34,6 @@
 #include <argp.h>
 #include <stdlib.h>
 #include <assert.h>
-#include <libintl.h>
 #include <fcntl.h>
 #include <unistd.h>
 
diff --git a/libdwfl/dwfl_error.c b/libdwfl/dwfl_error.c
index a5c683a9..43fa1dcc 100644
--- a/libdwfl/dwfl_error.c
+++ b/libdwfl/dwfl_error.c
@@ -31,7 +31,6 @@
 #endif
 
 #include <assert.h>
-#include <libintl.h>
 #include <stdbool.h>
 #include <stdint.h>
 #include <stdlib.h>
diff --git a/libebl/libeblP.h b/libebl/libeblP.h
index fa1c2c9f..c408ed97 100644
--- a/libebl/libeblP.h
+++ b/libebl/libeblP.h
@@ -32,7 +32,6 @@
 #include <gelf.h>
 #include <libasm.h>
 #include <libebl.h>
-#include <libintl.h>
 
 
 /* Backend handle.  */
diff --git a/src/addr2line.c b/src/addr2line.c
index 25db2926..7768b266 100644
--- a/src/addr2line.c
+++ b/src/addr2line.c
@@ -28,7 +28,6 @@
 #include <inttypes.h>
 #include <libdwfl.h>
 #include <dwarf.h>
-#include <libintl.h>
 #include <locale.h>
 #include <stdbool.h>
 #include <stdio.h>
diff --git a/src/ar.c b/src/ar.c
index 04456c18..3bcb18fe 100644
--- a/src/ar.c
+++ b/src/ar.c
@@ -24,7 +24,6 @@
 #include <assert.h>
 #include <fcntl.h>
 #include <gelf.h>
-#include <libintl.h>
 #include <limits.h>
 #include <locale.h>
 #include <search.h>
diff --git a/src/arlib-argp.c b/src/arlib-argp.c
index a3c12e4d..115b9d76 100644
--- a/src/arlib-argp.c
+++ b/src/arlib-argp.c
@@ -20,7 +20,6 @@
 #endif
 
 #include <argp.h>
-#include <libintl.h>
 
 #include "arlib.h"
 
diff --git a/src/arlib.c b/src/arlib.c
index c09fc3c6..b8f89ba7 100644
--- a/src/arlib.c
+++ b/src/arlib.c
@@ -23,7 +23,6 @@
 #include <assert.h>
 #include <gelf.h>
 #include <inttypes.h>
-#include <libintl.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <time.h>
diff --git a/src/arlib2.c b/src/arlib2.c
index 11f44e5d..9ae6662c 100644
--- a/src/arlib2.c
+++ b/src/arlib2.c
@@ -20,7 +20,6 @@
 # include <config.h>
 #endif
 
-#include <libintl.h>
 #include <limits.h>
 #include <string.h>
 
diff --git a/src/elfcmp.c b/src/elfcmp.c
index 21d8d9dc..fba67e02 100644
--- a/src/elfcmp.c
+++ b/src/elfcmp.c
@@ -25,7 +25,6 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <locale.h>
-#include <libintl.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/src/elflint.c b/src/elflint.c
index b0e5415e..565cffdc 100644
--- a/src/elflint.c
+++ b/src/elflint.c
@@ -27,7 +27,6 @@
 #include <fcntl.h>
 #include <gelf.h>
 #include <inttypes.h>
-#include <libintl.h>
 #include <locale.h>
 #include <stdbool.h>
 #include <stdlib.h>
diff --git a/src/findtextrel.c b/src/findtextrel.c
index ecb1d118..d3021a3a 100644
--- a/src/findtextrel.c
+++ b/src/findtextrel.c
@@ -26,7 +26,6 @@
 #include <fcntl.h>
 #include <gelf.h>
 #include <libdw.h>
-#include <libintl.h>
 #include <locale.h>
 #include <search.h>
 #include <stdbool.h>
diff --git a/src/nm.c b/src/nm.c
index 16647589..b46c1fd7 100644
--- a/src/nm.c
+++ b/src/nm.c
@@ -30,7 +30,6 @@
 #include <gelf.h>
 #include <inttypes.h>
 #include <libdw.h>
-#include <libintl.h>
 #include <locale.h>
 #include <obstack.h>
 #include <search.h>
diff --git a/src/objdump.c b/src/objdump.c
index b32de17d..d43c1dd6 100644
--- a/src/objdump.c
+++ b/src/objdump.c
@@ -23,7 +23,6 @@
 #include <argp.h>
 #include <fcntl.h>
 #include <inttypes.h>
-#include <libintl.h>
 #include <locale.h>
 #include <stdbool.h>
 #include <stdio.h>
diff --git a/src/ranlib.c b/src/ranlib.c
index bd7e1d8a..7838d69e 100644
--- a/src/ranlib.c
+++ b/src/ranlib.c
@@ -26,7 +26,6 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <gelf.h>
-#include <libintl.h>
 #include <locale.h>
 #include <obstack.h>
 #include <stdlib.h>
diff --git a/src/readelf.c b/src/readelf.c
index 1a10fd01..a206e60e 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -30,7 +30,6 @@
 #include <langinfo.h>
 #include <libdw.h>
 #include <libdwfl.h>
-#include <libintl.h>
 #include <locale.h>
 #include <stdarg.h>
 #include <stdbool.h>
diff --git a/src/size.c b/src/size.c
index 8f203167..ff8ca075 100644
--- a/src/size.c
+++ b/src/size.c
@@ -25,7 +25,6 @@
 #include <gelf.h>
 #include <inttypes.h>
 #include <libelf.h>
-#include <libintl.h>
 #include <locale.h>
 #include <stdbool.h>
 #include <stdio.h>
diff --git a/src/strings.c b/src/strings.c
index 04aac3b6..55b047be 100644
--- a/src/strings.c
+++ b/src/strings.c
@@ -28,7 +28,6 @@
 #include <fcntl.h>
 #include <gelf.h>
 #include <inttypes.h>
-#include <libintl.h>
 #include <locale.h>
 #include <stdbool.h>
 #include <stdio.h>
diff --git a/src/strip.c b/src/strip.c
index 452b1279..2a2cc801 100644
--- a/src/strip.c
+++ b/src/strip.c
@@ -28,7 +28,6 @@
 #include <fnmatch.h>
 #include <gelf.h>
 #include <libelf.h>
-#include <libintl.h>
 #include <locale.h>
 #include <stdbool.h>
 #include <stdio.h>
diff --git a/src/unstrip.c b/src/unstrip.c
index 3472637a..d5bd1821 100644
--- a/src/unstrip.c
+++ b/src/unstrip.c
@@ -33,7 +33,6 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <fnmatch.h>
-#include <libintl.h>
 #include <locale.h>
 #include <stdbool.h>
 #include <stdio.h>
-- 
2.36.1.windows.1


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH 5/7] Strip __ prefix from __BYTE_ORDER __LITTLE_ENDIAN and __BIG_ENDIAN
  2022-09-20  8:43 [PATCH 0/7] Enable building libelf of elfutils on win32 Yonggang Luo
                   ` (3 preceding siblings ...)
  2022-09-20  8:43 ` [PATCH 4/7] Remove duplicated " Yonggang Luo
@ 2022-09-20  8:43 ` Yonggang Luo
  2022-10-16 21:11   ` Mark Wielaard
  2022-09-20  8:43 ` [PATCH 6/7] Fixes building with msvc/clang mingw/gcc Yonggang Luo
  2022-09-20  8:43 ` [PATCH 7/7] Add CMake build files Yonggang Luo
  6 siblings, 1 reply; 26+ messages in thread
From: Yonggang Luo @ 2022-09-20  8:43 UTC (permalink / raw)
  To: elfutils-devel; +Cc: Yonggang Luo

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
 lib/system.h                         |  4 ++--
 libcpu/i386_disasm.c                 |  2 +-
 libcpu/memory-access.h               | 26 +++++++++++++-------------
 libcpu/riscv_disasm.c                |  2 +-
 libdw/memory-access.h                |  8 ++++----
 libdwfl/dwfl_segment_report_module.c |  2 +-
 libelf/common.h                      |  2 +-
 libelf/elf32_checksum.c              |  4 ++--
 libelf/elf32_xlatetof.c              |  4 ++--
 libelf/elf_getarsym.c                |  6 +++---
 src/arlib.h                          |  2 +-
 11 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/lib/system.h b/lib/system.h
index 48004df1..bbbe06c4 100644
--- a/lib/system.h
+++ b/lib/system.h
@@ -64,12 +64,12 @@ void error(int status, int errnum, const char *format, ...);
     exit (EXIT_FAILURE); \
   } while (0)
 
-#if __BYTE_ORDER == __LITTLE_ENDIAN
+#if BYTE_ORDER == LITTLE_ENDIAN
 # define LE32(n)	(n)
 # define LE64(n)	(n)
 # define BE32(n)	bswap_32 (n)
 # define BE64(n)	bswap_64 (n)
-#elif __BYTE_ORDER == __BIG_ENDIAN
+#elif BYTE_ORDER == BIG_ENDIAN
 # define BE32(n)	(n)
 # define BE64(n)	(n)
 # define LE32(n)	bswap_32 (n)
diff --git a/libcpu/i386_disasm.c b/libcpu/i386_disasm.c
index fd7340cc..40475b81 100644
--- a/libcpu/i386_disasm.c
+++ b/libcpu/i386_disasm.c
@@ -44,7 +44,7 @@
 
 #include "../libebl/libeblP.h"
 
-#define MACHINE_ENCODING __LITTLE_ENDIAN
+#define MACHINE_ENCODING LITTLE_ENDIAN
 #include "memory-access.h"
 
 
diff --git a/libcpu/memory-access.h b/libcpu/memory-access.h
index 779825fa..3b6ca19b 100644
--- a/libcpu/memory-access.h
+++ b/libcpu/memory-access.h
@@ -41,7 +41,7 @@
 #ifndef MACHINE_ENCODING
 # error "MACHINE_ENCODING needs to be defined"
 #endif
-#if MACHINE_ENCODING != __BIG_ENDIAN && MACHINE_ENCODING != __LITTLE_ENDIAN
+#if MACHINE_ENCODING != BIG_ENDIAN && MACHINE_ENCODING != LITTLE_ENDIAN
 # error "MACHINE_ENCODING must signal either big or little endian"
 #endif
 
@@ -51,31 +51,31 @@
 #if ALLOW_UNALIGNED
 
 # define read_2ubyte_unaligned(Addr) \
-  (unlikely (MACHINE_ENCODING != __BYTE_ORDER)				      \
+  (unlikely (MACHINE_ENCODING != BYTE_ORDER)				      \
    ? bswap_16 (*((const uint16_t *) (Addr)))				      \
    : *((const uint16_t *) (Addr)))
 # define read_2sbyte_unaligned(Addr) \
-  (unlikely (MACHINE_ENCODING != __BYTE_ORDER)				      \
+  (unlikely (MACHINE_ENCODING != BYTE_ORDER)				      \
    ? (int16_t) bswap_16 (*((const int16_t *) (Addr)))			      \
    : *((const int16_t *) (Addr)))
 
 # define read_4ubyte_unaligned_noncvt(Addr) \
    *((const uint32_t *) (Addr))
 # define read_4ubyte_unaligned(Addr) \
-  (unlikely (MACHINE_ENCODING != __BYTE_ORDER)				      \
+  (unlikely (MACHINE_ENCODING != BYTE_ORDER)				      \
    ? bswap_32 (*((const uint32_t *) (Addr)))				      \
    : *((const uint32_t *) (Addr)))
 # define read_4sbyte_unaligned(Addr) \
-  (unlikely (MACHINE_ENCODING != __BYTE_ORDER)				      \
+  (unlikely (MACHINE_ENCODING != BYTE_ORDER)				      \
    ? (int32_t) bswap_32 (*((const int32_t *) (Addr)))			      \
    : *((const int32_t *) (Addr)))
 
 # define read_8ubyte_unaligned(Addr) \
-  (unlikely (MACHINE_ENCODING != __BYTE_ORDER)				      \
+  (unlikely (MACHINE_ENCODING != BYTE_ORDER)				      \
    ? bswap_64 (*((const uint64_t *) (Addr)))				      \
    : *((const uint64_t *) (Addr)))
 # define read_8sbyte_unaligned(Addr) \
-  (unlikely (MACHINE_ENCODING != __BYTE_ORDER)				      \
+  (unlikely (MACHINE_ENCODING != BYTE_ORDER)				      \
    ? (int64_t) bswap_64 (*((const int64_t *) (Addr)))			      \
    : *((const int64_t *) (Addr)))
 
@@ -96,7 +96,7 @@ static inline uint16_t
 read_2ubyte_unaligned (const void *p)
 {
   const union unaligned *up = p;
-  if (MACHINE_ENCODING != __BYTE_ORDER)
+  if (MACHINE_ENCODING != BYTE_ORDER)
     return bswap_16 (up->u2);
   return up->u2;
 }
@@ -104,7 +104,7 @@ static inline int16_t
 read_2sbyte_unaligned (const void *p)
 {
   const union unaligned *up = p;
-  if (MACHINE_ENCODING != __BYTE_ORDER)
+  if (MACHINE_ENCODING != BYTE_ORDER)
     return (int16_t) bswap_16 (up->u2);
   return up->s2;
 }
@@ -119,7 +119,7 @@ static inline uint32_t
 read_4ubyte_unaligned (const void *p)
 {
   const union unaligned *up = p;
-  if (MACHINE_ENCODING != __BYTE_ORDER)
+  if (MACHINE_ENCODING != BYTE_ORDER)
     return bswap_32 (up->u4);
   return up->u4;
 }
@@ -127,7 +127,7 @@ static inline int32_t
 read_4sbyte_unaligned (const void *p)
 {
   const union unaligned *up = p;
-  if (MACHINE_ENCODING != __BYTE_ORDER)
+  if (MACHINE_ENCODING != BYTE_ORDER)
     return (int32_t) bswap_32 (up->u4);
   return up->s4;
 }
@@ -136,7 +136,7 @@ static inline uint64_t
 read_8ubyte_unaligned (const void *p)
 {
   const union unaligned *up = p;
-  if (MACHINE_ENCODING != __BYTE_ORDER)
+  if (MACHINE_ENCODING != BYTE_ORDER)
     return bswap_64 (up->u8);
   return up->u8;
 }
@@ -144,7 +144,7 @@ static inline int64_t
 read_8sbyte_unaligned (const void *p)
 {
   const union unaligned *up = p;
-  if (MACHINE_ENCODING != __BYTE_ORDER)
+  if (MACHINE_ENCODING != BYTE_ORDER)
     return (int64_t) bswap_64 (up->u8);
   return up->s8;
 }
diff --git a/libcpu/riscv_disasm.c b/libcpu/riscv_disasm.c
index bc0d8f37..7175c077 100644
--- a/libcpu/riscv_disasm.c
+++ b/libcpu/riscv_disasm.c
@@ -41,7 +41,7 @@
 
 #include "../libebl/libeblP.h"
 
-#define MACHINE_ENCODING __LITTLE_ENDIAN
+#define MACHINE_ENCODING LITTLE_ENDIAN
 #include "memory-access.h"
 
 
diff --git a/libdw/memory-access.h b/libdw/memory-access.h
index 8b2386ee..800b517c 100644
--- a/libdw/memory-access.h
+++ b/libdw/memory-access.h
@@ -355,10 +355,10 @@ read_8sbyte_unaligned_1 (bool other_byte_order, const void *p)
 static inline int
 file_byte_order (bool other_byte_order)
 {
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-  return other_byte_order ? __BIG_ENDIAN : __LITTLE_ENDIAN;
+#if BYTE_ORDER == LITTLE_ENDIAN
+  return other_byte_order ? BIG_ENDIAN : LITTLE_ENDIAN;
 #else
-  return other_byte_order ? __LITTLE_ENDIAN : __BIG_ENDIAN;
+  return other_byte_order ? LITTLE_ENDIAN : BIG_ENDIAN;
 #endif
 }
 
@@ -372,7 +372,7 @@ read_3ubyte_unaligned (Dwarf *dbg, const unsigned char *p)
   } d;
   bool other_byte_order = dbg->other_byte_order;
 
-  if (file_byte_order (other_byte_order) == __BIG_ENDIAN)
+  if (file_byte_order (other_byte_order) == BIG_ENDIAN)
     {
       d.c[0] = 0x00;
       d.c[1] = p[0];
diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c
index 1461ae26..28f87f10 100644
--- a/libdwfl/dwfl_segment_report_module.c
+++ b/libdwfl/dwfl_segment_report_module.c
@@ -49,7 +49,7 @@
 
 #define INITIAL_READ	1024
 
-#if __BYTE_ORDER == __LITTLE_ENDIAN
+#if BYTE_ORDER == LITTLE_ENDIAN
 # define MY_ELFDATA	ELFDATA2LSB
 #else
 # define MY_ELFDATA	ELFDATA2MSB
diff --git a/libelf/common.h b/libelf/common.h
index 4561854f..9b2a856d 100644
--- a/libelf/common.h
+++ b/libelf/common.h
@@ -151,7 +151,7 @@ libelf_release_all (Elf *elf)
 		 : bswap_64 (Var))))
 
 
-#if __BYTE_ORDER == __LITTLE_ENDIAN
+#if BYTE_ORDER == LITTLE_ENDIAN
 # define MY_ELFDATA	ELFDATA2LSB
 #else
 # define MY_ELFDATA	ELFDATA2MSB
diff --git a/libelf/elf32_checksum.c b/libelf/elf32_checksum.c
index 521668a7..a47b307d 100644
--- a/libelf/elf32_checksum.c
+++ b/libelf/elf32_checksum.c
@@ -73,9 +73,9 @@ elfw2(LIBELFBITS,checksum) (Elf *elf)
      is the same.  */
   ident = elf->state.ELFW(elf,LIBELFBITS).ehdr->e_ident;
   same_byte_order = ((ident[EI_DATA] == ELFDATA2LSB
-		      && __BYTE_ORDER == __LITTLE_ENDIAN)
+		      && BYTE_ORDER == LITTLE_ENDIAN)
 		     || (ident[EI_DATA] == ELFDATA2MSB
-			 && __BYTE_ORDER == __BIG_ENDIAN));
+			 && BYTE_ORDER == BIG_ENDIAN));
 
   /* If we don't have native byte order, we will likely need to
      convert the data with xlate functions.  We do it upfront instead
diff --git a/libelf/elf32_xlatetof.c b/libelf/elf32_xlatetof.c
index 377659c8..ab857409 100644
--- a/libelf/elf32_xlatetof.c
+++ b/libelf/elf32_xlatetof.c
@@ -82,8 +82,8 @@ elfw2(LIBELFBITS, xlatetof) (Elf_Data *dest, const Elf_Data *src,
 	and vice versa since the function only has to copy and/or
 	change the byte order.
   */
-  if ((__BYTE_ORDER == __LITTLE_ENDIAN && encode == ELFDATA2LSB)
-      || (__BYTE_ORDER == __BIG_ENDIAN && encode == ELFDATA2MSB))
+  if ((BYTE_ORDER == LITTLE_ENDIAN && encode == ELFDATA2LSB)
+      || (BYTE_ORDER == BIG_ENDIAN && encode == ELFDATA2MSB))
     {
       /* We simply have to copy since the byte order is the same.  */
       if (src->d_buf != dest->d_buf)
diff --git a/libelf/elf_getarsym.c b/libelf/elf_getarsym.c
index 2203521f..281f0c1c 100644
--- a/libelf/elf_getarsym.c
+++ b/libelf/elf_getarsym.c
@@ -61,7 +61,7 @@ read_number_entries (uint64_t *nump, Elf *elf, size_t *offp, bool index64_p)
 
   *offp += w;
 
-  if (__BYTE_ORDER == __LITTLE_ENDIAN)
+  if (BYTE_ORDER == LITTLE_ENDIAN)
     *nump = index64_p ? bswap_64 (u.ret64) : bswap_32 (u.ret32);
   else
     *nump = index64_p ? u.ret64 : u.ret32;
@@ -266,7 +266,7 @@ elf_getarsym (Elf *elf, size_t *ptr)
 	      if (index64_p)
 		{
 		  uint64_t tmp = (*u64)[cnt];
-		  if (__BYTE_ORDER == __LITTLE_ENDIAN)
+		  if (BYTE_ORDER == LITTLE_ENDIAN)
 		    tmp = bswap_64 (tmp);
 
 		  arsym[cnt].as_off = tmp;
@@ -286,7 +286,7 @@ elf_getarsym (Elf *elf, size_t *ptr)
 		      goto out;
 		    }
 		}
-	      else if (__BYTE_ORDER == __LITTLE_ENDIAN)
+	      else if (BYTE_ORDER == LITTLE_ENDIAN)
 		arsym[cnt].as_off = bswap_32 ((*u32)[cnt]);
 	      else
 		arsym[cnt].as_off = (*u32)[cnt];
diff --git a/src/arlib.h b/src/arlib.h
index e117166e..d4a42210 100644
--- a/src/arlib.h
+++ b/src/arlib.h
@@ -46,7 +46,7 @@ extern const struct argp_child arlib_argp_children[];
 #define AR_HDR_WORDS (sizeof (struct ar_hdr) / sizeof (uint32_t))
 
 
-#if __BYTE_ORDER == __LITTLE_ENDIAN
+#if BYTE_ORDER == LITTLE_ENDIAN
 # define le_bswap_32(val) bswap_32 (val)
 #else
 # define le_bswap_32(val) (val)
-- 
2.36.1.windows.1


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH 6/7] Fixes building with msvc/clang mingw/gcc
  2022-09-20  8:43 [PATCH 0/7] Enable building libelf of elfutils on win32 Yonggang Luo
                   ` (4 preceding siblings ...)
  2022-09-20  8:43 ` [PATCH 5/7] Strip __ prefix from __BYTE_ORDER __LITTLE_ENDIAN and __BIG_ENDIAN Yonggang Luo
@ 2022-09-20  8:43 ` Yonggang Luo
  2022-10-16 21:21   ` Mark Wielaard
  2022-09-20  8:43 ` [PATCH 7/7] Add CMake build files Yonggang Luo
  6 siblings, 1 reply; 26+ messages in thread
From: Yonggang Luo @ 2022-09-20  8:43 UTC (permalink / raw)
  To: elfutils-devel; +Cc: Yonggang Luo

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
 configure.ac              |   1 +
 lib/system.h              |  61 +++++++++++++-
 lib/system_win32.c        | 162 ++++++++++++++++++++++++++++++++++++++
 libelf/elf32_updatefile.c |   3 +-
 libelf/elf_begin.c        |   7 +-
 libelf/elf_end.c          |   2 +
 libelf/elf_update.c       |   5 +-
 libelf/libelf.h           |   6 ++
 libelf/libelfP.h          |   4 +
 libelf/win32/ar.h         |  52 ++++++++++++
 10 files changed, 298 insertions(+), 5 deletions(-)
 create mode 100644 lib/system_win32.c
 create mode 100644 libelf/win32/ar.h

diff --git a/configure.ac b/configure.ac
index 03b67a9d..63aeb748 100644
--- a/configure.ac
+++ b/configure.ac
@@ -428,6 +428,7 @@ AC_CHECK_DECLS([memrchr, rawmemchr],[],[],
                [#define _GNU_SOURCE
                 #include <string.h>])
 AC_CHECK_DECLS([powerof2],[],[],[#include <sys/param.h>])
+AC_CHECK_DECLS([mmap],[],[],[#include <sys/mman.h>])
 AC_CHECK_DECLS([mempcpy],[],[],
                [#define _GNU_SOURCE
                 #include <string.h>])
diff --git a/lib/system.h b/lib/system.h
index bbbe06c4..05b5cf8d 100644
--- a/lib/system.h
+++ b/lib/system.h
@@ -40,21 +40,78 @@
 #include <stdlib.h>
 
 /* System dependend headers */
+#if !defined(_WIN32)
 #include <byteswap.h>
 #include <endian.h>
-#include <sys/mman.h>
+#endif
+
+#if defined(_MSC_VER)
+#include <basetsd.h>
+#include <io.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <sys/types.h>
+typedef SSIZE_T ssize_t;
+#else
 #include <sys/param.h>
 #include <unistd.h>
+#endif
+
+#if HAVE_DECL_MMAP
+#include <sys/mman.h>
+#endif
 
 #if defined(HAVE_ERROR_H)
 #include <error.h>
-#elif defined(HAVE_ERR_H)
+#elif defined(HAVE_ERR_H) || defined(_MSC_VER)
 extern int error_message_count;
 void error(int status, int errnum, const char *format, ...);
 #else
 #error "err.h or error.h must be available"
 #endif
 
+#if defined(_MSC_VER)
+#define BIG_ENDIAN 4321
+#define LITTLE_ENDIAN 1234
+#define BYTE_ORDER LITTLE_ENDIAN
+static inline int ftruncate(int fd, off_t length)
+{
+     return _chsize_s(fd, length);
+}
+#endif /* defined(_MSC_VER) */
+
+#if defined(_WIN32)
+static inline uint16_t bswap_16(uint16_t x) {
+  return ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8));
+}
+
+static inline uint32_t bswap_32(uint32_t x) {
+  return (
+    (((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >>  8) |
+    (((x) & 0x0000ff00) <<  8) | (((x) & 0x000000ff) << 24)
+  );
+}
+
+static inline uint64_t bswap_64(uint64_t x) {
+  return (
+    (((x) & 0xff00000000000000ull) >> 56) |
+    (((x) & 0x00ff000000000000ull) >> 40) |
+    (((x) & 0x0000ff0000000000ull) >> 24) |
+    (((x) & 0x000000ff00000000ull) >> 8)  |
+    (((x) & 0x00000000ff000000ull) << 8)  |
+    (((x) & 0x0000000000ff0000ull) << 24) |
+    (((x) & 0x000000000000ff00ull) << 40) |
+    (((x) & 0x00000000000000ffull) << 56)
+  );
+}
+
+#define htobe64(x) bswap_64(x)
+#define be64toh(x) bswap_64(x)
+
+ssize_t pread(int fd, void *buf, size_t count, off_t offset);
+ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset);
+#endif /* defined(_WIN32) */
+
 /* error (EXIT_FAILURE, ...) should be noreturn but on some systems it
    isn't.  This may cause warnings about code that should not be reachable.
    So have an explicit error_exit wrapper that is noreturn (because it
diff --git a/lib/system_win32.c b/lib/system_win32.c
new file mode 100644
index 00000000..d9941cc5
--- /dev/null
+++ b/lib/system_win32.c
@@ -0,0 +1,162 @@
+/* Copyright (C) 2022 Yonggang Luo
+   This file is part of elfutils.
+
+   This file is free software; you can redistribute it and/or modify
+   it under the terms of either
+
+     * the GNU Lesser General Public License as published by the Free
+       Software Foundation; either version 3 of the License, or (at
+       your option) any later version
+
+   or
+
+     * the GNU General Public License as published by the Free
+       Software Foundation; either version 2 of the License, or (at
+       your option) any later version
+
+   or both in parallel, as here.
+
+   elfutils is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received copies of the GNU General Public License and
+   the GNU Lesser General Public License along with this program.  If
+   not, see <http://www.gnu.org/licenses/>.  */
+
+#include <errno.h>
+#include "system.h"
+
+#include <windows.h>
+
+static const struct
+{
+  DWORD winerr;
+  int doserr;
+} doserrors[] =
+
+    {
+        {ERROR_INVALID_FUNCTION, EINVAL},
+        {ERROR_FILE_NOT_FOUND, ENOENT},
+        {ERROR_PATH_NOT_FOUND, ENOENT},
+        {ERROR_TOO_MANY_OPEN_FILES, EMFILE},
+        {ERROR_ACCESS_DENIED, EACCES},
+        {ERROR_INVALID_HANDLE, EBADF},
+        {ERROR_ARENA_TRASHED, ENOMEM},
+        {ERROR_NOT_ENOUGH_MEMORY, ENOMEM},
+        {ERROR_INVALID_BLOCK, ENOMEM},
+        {ERROR_BAD_ENVIRONMENT, E2BIG},
+        {ERROR_BAD_FORMAT, ENOEXEC},
+        {ERROR_INVALID_ACCESS, EINVAL},
+        {ERROR_INVALID_DATA, EINVAL},
+        {ERROR_INVALID_DRIVE, ENOENT},
+        {ERROR_CURRENT_DIRECTORY, EACCES},
+        {ERROR_NOT_SAME_DEVICE, EXDEV},
+        {ERROR_NO_MORE_FILES, ENOENT},
+        {ERROR_LOCK_VIOLATION, EACCES},
+        {ERROR_SHARING_VIOLATION, EACCES},
+        {ERROR_BAD_NETPATH, ENOENT},
+        {ERROR_NETWORK_ACCESS_DENIED, EACCES},
+        {ERROR_BAD_NET_NAME, ENOENT},
+        {ERROR_FILE_EXISTS, EEXIST},
+        {ERROR_CANNOT_MAKE, EACCES},
+        {ERROR_FAIL_I24, EACCES},
+        {ERROR_INVALID_PARAMETER, EINVAL},
+        {ERROR_NO_PROC_SLOTS, EAGAIN},
+        {ERROR_DRIVE_LOCKED, EACCES},
+        {ERROR_BROKEN_PIPE, EPIPE},
+        {ERROR_DISK_FULL, ENOSPC},
+        {ERROR_INVALID_TARGET_HANDLE, EBADF},
+        {ERROR_INVALID_HANDLE, EINVAL},
+        {ERROR_WAIT_NO_CHILDREN, ECHILD},
+        {ERROR_CHILD_NOT_COMPLETE, ECHILD},
+        {ERROR_DIRECT_ACCESS_HANDLE, EBADF},
+        {ERROR_NEGATIVE_SEEK, EINVAL},
+        {ERROR_SEEK_ON_DEVICE, EACCES},
+        {ERROR_DIR_NOT_EMPTY, ENOTEMPTY},
+        {ERROR_NOT_LOCKED, EACCES},
+        {ERROR_BAD_PATHNAME, ENOENT},
+        {ERROR_MAX_THRDS_REACHED, EAGAIN},
+        {ERROR_LOCK_FAILED, EACCES},
+        {ERROR_ALREADY_EXISTS, EEXIST},
+        {ERROR_FILENAME_EXCED_RANGE, ENOENT},
+        {ERROR_NESTING_NOT_ALLOWED, EAGAIN},
+        {ERROR_NOT_ENOUGH_QUOTA, ENOMEM},
+        {ERROR_DELETE_PENDING, ENOENT}};
+
+static void
+_dosmaperr(unsigned long e)
+{
+  int i;
+
+  if (e == 0)
+  {
+    errno = 0;
+    return;
+  }
+
+  for (i = 0; i < sizeof(doserrors) / sizeof(doserrors[0]); i++)
+  {
+    if (doserrors[i].winerr == e)
+    {
+      int doserr = doserrors[i].doserr;
+
+      errno = doserr;
+      return;
+    }
+  }
+
+  errno = EINVAL;
+}
+
+ssize_t
+pread(int fd, void *buf, size_t count, off_t offset)
+{
+  OVERLAPPED overlapped = {0};
+  HANDLE h;
+  DWORD ret;
+
+  h = (HANDLE)_get_osfhandle(fd);
+  if (h == INVALID_HANDLE_VALUE)
+  {
+    errno = EBADF;
+    return -1;
+  }
+
+  overlapped.Offset = offset;
+  if (!ReadFile(h, buf, count, &ret, &overlapped))
+  {
+    if (GetLastError() == ERROR_HANDLE_EOF)
+      return 0;
+
+    _dosmaperr(GetLastError());
+    return -1;
+  }
+
+  return ret;
+}
+
+ssize_t
+pwrite(int fd, const void *buf, size_t count, off_t offset)
+{
+  OVERLAPPED overlapped = {0};
+  HANDLE h;
+  DWORD ret;
+
+  h = (HANDLE)_get_osfhandle(fd);
+  if (h == INVALID_HANDLE_VALUE)
+  {
+    errno = EBADF;
+    return -1;
+  }
+
+  overlapped.Offset = offset;
+  if (!WriteFile(h, buf, count, &ret, &overlapped))
+  {
+    _dosmaperr(GetLastError());
+    return -1;
+  }
+
+  return ret;
+}
diff --git a/libelf/elf32_updatefile.c b/libelf/elf32_updatefile.c
index 46afa1f4..8229fd26 100644
--- a/libelf/elf32_updatefile.c
+++ b/libelf/elf32_updatefile.c
@@ -96,7 +96,7 @@ sort_sections (Elf_Scn **scns, Elf_ScnList *list)
   qsort (scns, scnp - scns, sizeof (*scns), compare_sections);
 }
 
-
+#if HAVE_DECL_MMAP
 static inline void
 fill_mmap (size_t offset, char *last_position, char *scn_start,
            char *const shdr_start, char *const shdr_end)
@@ -482,6 +482,7 @@ __elfw2(LIBELFBITS,updatemmap) (Elf *elf, int change_bo, size_t shnum)
 
   return 0;
 }
+#endif
 
 
 /* Size of the buffer we use to generate the blocks of fill bytes.  */
diff --git a/libelf/elf_begin.c b/libelf/elf_begin.c
index fe8c640a..d867cd6f 100644
--- a/libelf/elf_begin.c
+++ b/libelf/elf_begin.c
@@ -645,10 +645,12 @@ static struct Elf *
 read_file (int fildes, int64_t offset, size_t maxsize,
 	   Elf_Cmd cmd, Elf *parent)
 {
+#if HAVE_DECL_MMAP
   void *map_address = NULL;
   int use_mmap = (cmd == ELF_C_READ_MMAP || cmd == ELF_C_RDWR_MMAP
 		  || cmd == ELF_C_WRITE_MMAP
 		  || cmd == ELF_C_READ_MMAP_PRIVATE);
+#endif
 
   if (parent == NULL)
     {
@@ -669,7 +671,7 @@ read_file (int fildes, int64_t offset, size_t maxsize,
       /* The parent is already loaded.  Use it.  */
       assert (maxsize != ~((size_t) 0));
     }
-
+#if HAVE_DECL_MMAP
   if (use_mmap)
     {
       if (parent == NULL)
@@ -713,6 +715,7 @@ read_file (int fildes, int64_t offset, size_t maxsize,
 
       return result;
     }
+#endif
 
   /* Otherwise we have to do it the hard way.  We read as much as necessary
      from the file whenever we need information which is not available.  */
@@ -1160,12 +1163,14 @@ elf_begin (int fildes, Elf_Cmd cmd, Elf *ref)
   if (ref != NULL)
     /* Make sure the descriptor is not suddenly going away.  */
     rwlock_rdlock (ref->lock);
+#if defined(F_GETFD)
   else if (unlikely (fcntl (fildes, F_GETFD) == -1 && errno == EBADF))
     {
       /* We cannot do anything productive without a file descriptor.  */
       __libelf_seterrno (ELF_E_INVALID_FILE);
       return NULL;
     }
+#endif
 
   switch (cmd)
     {
diff --git a/libelf/elf_end.c b/libelf/elf_end.c
index 5c451f36..8023b216 100644
--- a/libelf/elf_end.c
+++ b/libelf/elf_end.c
@@ -222,8 +222,10 @@ elf_end (Elf *elf)
       /* The file was read or mapped for this descriptor.  */
       if ((elf->flags & ELF_F_MALLOCED) != 0)
 	free (elf->map_address);
+#if HAVE_DECL_MMAP
       else if ((elf->flags & ELF_F_MMAPPED) != 0)
 	munmap (elf->map_address, elf->maximum_size);
+#endif
     }
 
   rwlock_unlock (elf->lock);
diff --git a/libelf/elf_update.c b/libelf/elf_update.c
index 56af3a1c..e81eb6c9 100644
--- a/libelf/elf_update.c
+++ b/libelf/elf_update.c
@@ -64,7 +64,7 @@ write_file (Elf *elf, int64_t size, int change_bo, size_t shnum)
       __libelf_seterrno (ELF_E_WRITE_ERROR);
       return -1;
     }
-
+#if HAVE_DECL_MMAP
   /* Try to map the file if this isn't done yet.  */
   if (elf->map_address == NULL && elf->cmd == ELF_C_WRITE_MMAP)
     {
@@ -125,6 +125,7 @@ write_file (Elf *elf, int64_t size, int change_bo, size_t shnum)
 	size = -1;
     }
   else
+#endif
     {
       /* The file is not mmaped.  */
       if ((class == ELFCLASS32
@@ -145,6 +146,7 @@ write_file (Elf *elf, int64_t size, int change_bo, size_t shnum)
       size = -1;
     }
 
+#if HAVE_DECL_MMAP
   /* POSIX says that ftruncate and write may clear the S_ISUID and S_ISGID
      mode bits.  So make sure we restore them afterwards if they were set.
      This is not atomic if someone else chmod's the file while we operate.  */
@@ -156,6 +158,7 @@ write_file (Elf *elf, int64_t size, int change_bo, size_t shnum)
       __libelf_seterrno (ELF_E_WRITE_ERROR);
       size = -1;
     }
+#endif
 
   if (size != -1 && elf->parent == NULL)
     elf->maximum_size = size;
diff --git a/libelf/libelf.h b/libelf/libelf.h
index a139e733..2fa3838b 100644
--- a/libelf/libelf.h
+++ b/libelf/libelf.h
@@ -195,9 +195,15 @@ typedef struct
 {
   char *ar_name;		/* Name of archive member.  */
   time_t ar_date;		/* File date.  */
+#if defined(_WIN32)
+  long ar_uid;
+  long ar_gid;
+  unsigned long ar_mode;
+#else
   uid_t ar_uid;			/* User ID.  */
   gid_t ar_gid;			/* Group ID.  */
   mode_t ar_mode;		/* File mode.  */
+#endif
   int64_t ar_size;		/* File size.  */
   char *ar_rawname;		/* Original name of archive member.  */
 } Elf_Arhdr;
diff --git a/libelf/libelfP.h b/libelf/libelfP.h
index d88a613c..14b60bce 100644
--- a/libelf/libelfP.h
+++ b/libelf/libelfP.h
@@ -30,7 +30,11 @@
 #ifndef _LIBELFP_H
 #define _LIBELFP_H 1
 
+#if defined(_WIN32)
+#include "win32/ar.h"
+#else
 #include <ar.h>
+#endif
 #include <gelf.h>
 
 #include <errno.h>
diff --git a/libelf/win32/ar.h b/libelf/win32/ar.h
new file mode 100644
index 00000000..d67fab52
--- /dev/null
+++ b/libelf/win32/ar.h
@@ -0,0 +1,52 @@
+/* Copyright (C) 2022 Yonggang Luo
+   This file is part of elfutils.
+
+   This file is free software; you can redistribute it and/or modify
+   it under the terms of either
+
+     * the GNU Lesser General Public License as published by the Free
+       Software Foundation; either version 3 of the License, or (at
+       your option) any later version
+
+   or
+
+     * the GNU General Public License as published by the Free
+       Software Foundation; either version 2 of the License, or (at
+       your option) any later version
+
+   or both in parallel, as here.
+
+   elfutils is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received copies of the GNU General Public License and
+   the GNU Lesser General Public License along with this program.  If
+   not, see <http://www.gnu.org/licenses/>.  */
+
+#ifndef _AR_H
+#define _AR_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define ARMAG "!<arch>\n"
+#define SARMAG 8
+#define ARFMAG "`\n"
+
+struct ar_hdr {
+	char ar_name[16];
+	char ar_date[12];
+	char ar_uid[6], ar_gid[6];
+	char ar_mode[8];
+	char ar_size[10];
+	char ar_fmag[2];
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
-- 
2.36.1.windows.1


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH 7/7] Add CMake build files
  2022-09-20  8:43 [PATCH 0/7] Enable building libelf of elfutils on win32 Yonggang Luo
                   ` (5 preceding siblings ...)
  2022-09-20  8:43 ` [PATCH 6/7] Fixes building with msvc/clang mingw/gcc Yonggang Luo
@ 2022-09-20  8:43 ` Yonggang Luo
  2022-10-16 21:23   ` Mark Wielaard
  6 siblings, 1 reply; 26+ messages in thread
From: Yonggang Luo @ 2022-09-20  8:43 UTC (permalink / raw)
  To: elfutils-devel; +Cc: Yonggang Luo

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
 .gitignore                   |   1 +
 CMakeLists.txt               |  47 +++++++++
 libelf/CMakeLists.txt        | 192 +++++++++++++++++++++++++++++++++++
 libelf/config-cmake/config.h |  27 +++++
 4 files changed, 267 insertions(+)
 create mode 100644 CMakeLists.txt
 create mode 100644 libelf/CMakeLists.txt
 create mode 100644 libelf/config-cmake/config.h

diff --git a/.gitignore b/.gitignore
index 8bcd88d7..ca06dddd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,6 +21,7 @@ Makefile.in
 /INSTALL
 /aclocal.m4
 /autom4te.*
+/build
 /config.cache
 /config.h
 /config.h.in
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 00000000..11ad5c13
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,47 @@
+# Copyright (C) 2022 Yonggang Luo
+# This file is part of elfutils.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# elfutils is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+cmake_minimum_required(VERSION 3.16)
+project(libelf
+    LANGUAGES C
+    VERSION 0.187
+)
+
+add_subdirectory(libelf)
+
+include(GNUInstallDirs)
+
+if (LIBELF_INSTALL)
+    # Install the targets
+    install(TARGETS elf
+        ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+        PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libelf
+    )
+    set(VERSION ${CMAKE_PROJECT_VERSION})
+    set(prefix ${CMAKE_INSTALL_PREFIX})
+    set(exec_prefix "\${prefix}")
+    set(libdir "\${exec_prefix}/lib")
+    set(includedir "\${prefix}/include/libelf")
+    configure_file(
+        ${CMAKE_CURRENT_SOURCE_DIR}/config/libelf.pc.in
+        ${CMAKE_CURRENT_BINARY_DIR}/libelf.pc
+        @ONLY
+    )
+    install(
+        FILES ${CMAKE_CURRENT_BINARY_DIR}/libelf.pc
+        DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
+    )
+endif()
diff --git a/libelf/CMakeLists.txt b/libelf/CMakeLists.txt
new file mode 100644
index 00000000..dc8f9291
--- /dev/null
+++ b/libelf/CMakeLists.txt
@@ -0,0 +1,192 @@
+# Copyright (C) 2022 Yonggang Luo
+# This file is part of elfutils.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# elfutils is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+add_library(elf
+    elf_begin.c
+    elf_clone.c
+    elf_cntl.c
+    elf_compress_gnu.c
+    elf_compress.c
+    elf_end.c
+    elf_error.c
+    elf_fill.c
+    elf_flagdata.c
+    elf_flagehdr.c
+    elf_flagelf.c
+    elf_flagphdr.c
+    elf_flagscn.c
+    elf_flagshdr.c
+    elf_getarhdr.c
+    elf_getaroff.c
+    elf_getarsym.c
+    elf_getbase.c
+    elf_getdata_rawchunk.c
+    elf_getdata.c
+    elf_getident.c
+    elf_getphdrnum.c
+    elf_getscn.c
+    elf_getshdrnum.c
+    elf_getshdrstrndx.c
+    elf_gnu_hash.c
+    elf_hash.c
+    elf_kind.c
+    elf_memory.c
+    elf_ndxscn.c
+    elf_newdata.c
+    elf_newscn.c
+    elf_next.c
+    elf_nextscn.c
+    elf_rand.c
+    elf_rawdata.c
+    elf_rawfile.c
+    elf_readall.c
+    elf_scnshndx.c
+    elf_strptr.c
+    elf_update.c
+    elf_version.c
+    elf32_checksum.c
+    elf32_fsize.c
+    elf32_getchdr.c
+    elf32_getehdr.c
+    elf32_getphdr.c
+    elf32_getshdr.c
+    elf32_newehdr.c
+    elf32_newphdr.c
+    elf32_offscn.c
+    elf32_updatefile.c
+    elf32_updatenull.c
+    elf32_xlatetof.c
+    elf32_xlatetom.c
+    elf64_checksum.c
+    elf64_fsize.c
+    elf64_getchdr.c
+    elf64_getehdr.c
+    elf64_getphdr.c
+    elf64_getshdr.c
+    elf64_newehdr.c
+    elf64_newphdr.c
+    elf64_offscn.c
+    elf64_updatefile.c
+    elf64_updatenull.c
+    elf64_xlatetof.c
+    elf64_xlatetom.c
+    gelf_checksum.c
+    gelf_fsize.c
+    gelf_getauxv.c
+    gelf_getchdr.c
+    gelf_getclass.c
+    gelf_getdyn.c
+    gelf_getehdr.c
+    gelf_getlib.c
+    gelf_getmove.c
+    gelf_getnote.c
+    gelf_getphdr.c
+    gelf_getrel.c
+    gelf_getrela.c
+    gelf_getshdr.c
+    gelf_getsym.c
+    gelf_getsyminfo.c
+    gelf_getsymshndx.c
+    gelf_getverdaux.c
+    gelf_getverdef.c
+    gelf_getvernaux.c
+    gelf_getverneed.c
+    gelf_getversym.c
+    gelf_newehdr.c
+    gelf_newphdr.c
+    gelf_offscn.c
+    gelf_update_auxv.c
+    gelf_update_dyn.c
+    gelf_update_ehdr.c
+    gelf_update_lib.c
+    gelf_update_move.c
+    gelf_update_phdr.c
+    gelf_update_rel.c
+    gelf_update_rela.c
+    gelf_update_shdr.c
+    gelf_update_sym.c
+    gelf_update_syminfo.c
+    gelf_update_symshndx.c
+    gelf_update_verdaux.c
+    gelf_update_verdef.c
+    gelf_update_vernaux.c
+    gelf_update_verneed.c
+    gelf_update_versym.c
+    gelf_xlate.c
+    gelf_xlatetof.c
+    gelf_xlatetom.c
+    libelf_crc32.c
+    libelf_next_prime.c
+    nlist.c
+)
+if(WIN32)
+    target_sources(
+        elf PRIVATE
+        ../lib/system_win32.c
+    )
+endif()
+set(ELF_PUBLIC_HEADERS
+    ${CMAKE_CURRENT_SOURCE_DIR}/gelf.h
+    ${CMAKE_CURRENT_SOURCE_DIR}/libelf.h
+    ${CMAKE_CURRENT_SOURCE_DIR}/nlist.h
+    ${CMAKE_CURRENT_SOURCE_DIR}/elf.h
+)
+set_target_properties(
+    elf PROPERTIES PUBLIC_HEADER
+    "${ELF_PUBLIC_HEADERS}"
+)
+target_include_directories(
+    elf PRIVATE
+    ${CMAKE_CURRENT_SOURCE_DIR}/../lib
+    ${CMAKE_CURRENT_SOURCE_DIR}/
+    ${CMAKE_CURRENT_SOURCE_DIR}/config-cmake
+)
+target_compile_definitions(
+    elf PRIVATE
+    -DHAVE_CONFIG_H
+)
+if (MSVC)
+    target_compile_definitions(
+        elf PRIVATE
+        -D_CRT_NONSTDC_NO_DEPRECATE
+        -D_CRT_SECURE_NO_WARNINGS
+        -D_CRT_SECURE_NO_WARNINGS_GLOBALS
+    )
+else()
+    target_compile_definitions(
+        elf PRIVATE
+        -D_FILE_OFFSET_BITS=64
+    )
+endif()
+set_property(TARGET elf PROPERTY C_STANDARD 11)
+
+if (MSVC)
+  # Enable find libz.a with msvc
+  set(CMAKE_FIND_LIBRARY_PREFIXES "" "lib")
+  set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib" ".a")
+endif()
+find_package(ZLIB REQUIRED)
+target_link_libraries(elf ZLIB::ZLIB)
+
+find_package(Intl)
+if (TARGET Intl::Intl)
+    target_link_libraries(elf Intl::Intl)
+else()
+    target_compile_definitions(
+        elf PRIVATE
+        -DNOT_HAVE_LIBINTL
+    )
+endif()
diff --git a/libelf/config-cmake/config.h b/libelf/config-cmake/config.h
new file mode 100644
index 00000000..25f1da57
--- /dev/null
+++ b/libelf/config-cmake/config.h
@@ -0,0 +1,27 @@
+#ifndef _CONFIG_H_
+#define _GNU_SOURCE
+#include "eu-config.h"
+
+#if defined(_WIN32)
+#define HAVE_DECL_MEMPCPY 0
+#define HAVE_DECL_MEMRCHR 0
+#define HAVE_DECL_POWEROF2 0
+#define HAVE_DECL_MMAP 0
+#else
+#define HAVE_DECL_MEMPCPY 1
+#define HAVE_DECL_MEMRCHR 1
+#define HAVE_DECL_POWEROF2 1
+#define HAVE_DECL_MMAP 1
+#endif
+#define HAVE_DECL_RAWMEMCHR 0
+#define HAVE_DECL_REALLOCARRAY 1
+#define HAVE_VISIBILITY 1
+
+#undef HAVE_GCC_STRUCT
+#undef USE_LOCKS
+
+#if !defined(_MSC_VER)
+#define HAVE_ERROR_H
+#endif
+
+#endif /* _CONFIG_H_ */
\ No newline at end of file
-- 
2.36.1.windows.1


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 1/7] Rename 'hello2.spec.' -> 'hello2.spec' 'hello3.spec.' -> 'hello3.spec'
  2022-09-20  8:43 ` [PATCH 1/7] Rename 'hello2.spec.' -> 'hello2.spec' 'hello3.spec.' -> 'hello3.spec' Yonggang Luo
@ 2022-10-14 20:35   ` Mark Wielaard
  2022-10-19 18:45     ` 罗勇刚(Yonggang Luo)
  0 siblings, 1 reply; 26+ messages in thread
From: Mark Wielaard @ 2022-10-14 20:35 UTC (permalink / raw)
  To: Yonggang Luo; +Cc: elfutils-devel

Hi,

On Tue, Sep 20, 2022 at 04:43:01PM +0800, Yonggang Luo via Elfutils-devel wrote:
> These filenames are invalid on win32

This looks ok to me, but I don't really know why these files were
named this way in the first place.

The files themselves are not directly used, they are there to recreate
the hello3*rpm test files.

Frank, would you mind if these are just renamed to normal *.spec?

Thanks,

Mark

> Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
> ---
>  tests/Makefile.am                                   | 2 +-
>  tests/debuginfod-rpms/{hello2.spec. => hello2.spec} | 0
>  tests/debuginfod-rpms/{hello3.spec. => hello3.spec} | 0
>  3 files changed, 1 insertion(+), 1 deletion(-)
>  rename tests/debuginfod-rpms/{hello2.spec. => hello2.spec} (100%)
>  rename tests/debuginfod-rpms/{hello3.spec. => hello3.spec} (100%)
> 
> diff --git a/tests/Makefile.am b/tests/Makefile.am
> index 85514898..fc2235f4 100644
> --- a/tests/Makefile.am
> +++ b/tests/Makefile.am
> @@ -563,7 +563,7 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh run-ar.sh \
>  	     debuginfod-rpms/fedora31/hello3-debugsource-1.0-2.x86_64.rpm \
>  	     debuginfod-rpms/fedora31/hello3-two-1.0-2.x86_64.rpm \
>  	     debuginfod-rpms/fedora31/hello3-two-debuginfo-1.0-2.x86_64.rpm \
> -	     debuginfod-rpms/hello2.spec. \
> +	     debuginfod-rpms/hello2.spec \
>  	     debuginfod-rpms/rhel6/hello2-1.0-2.i686.rpm \
>  	     debuginfod-rpms/rhel6/hello2-1.0-2.src.rpm \
>  	     debuginfod-rpms/rhel6/hello2-debuginfo-1.0-2.i686.rpm \
> diff --git a/tests/debuginfod-rpms/hello2.spec. b/tests/debuginfod-rpms/hello2.spec
> similarity index 100%
> rename from tests/debuginfod-rpms/hello2.spec.
> rename to tests/debuginfod-rpms/hello2.spec
> diff --git a/tests/debuginfod-rpms/hello3.spec. b/tests/debuginfod-rpms/hello3.spec
> similarity index 100%
> rename from tests/debuginfod-rpms/hello3.spec.
> rename to tests/debuginfod-rpms/hello3.spec
> -- 
> 2.36.1.windows.1
> 

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 2/7] move platform depended include into system.h
  2022-09-20  8:43 ` [PATCH 2/7] move platform depended include into system.h Yonggang Luo
@ 2022-10-14 21:16   ` Mark Wielaard
  2022-10-15 17:01     ` 罗勇刚(Yonggang Luo)
  0 siblings, 1 reply; 26+ messages in thread
From: Mark Wielaard @ 2022-10-14 21:16 UTC (permalink / raw)
  To: Yonggang Luo; +Cc: elfutils-devel

On Tue, Sep 20, 2022 at 04:43:02PM +0800, Yonggang Luo via Elfutils-devel wrote:
> All of these files either #include <system.h> directly or #include "libelfP.h"
> And now "libelfP.h also #include <system.h>, so the platform depended include
> can be moved to system.h safely

I like this in theory since it cleans up some of the includes.
But it doesn't work as is.

libebl/eblobjnotetypename.c only included system.h so now doesn't
compile anymore.  And libintl.h is removed from libelf/elf_error.c
which really is necessary.

Cheers,

Mark

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 2/7] move platform depended include into system.h
  2022-10-14 21:16   ` Mark Wielaard
@ 2022-10-15 17:01     ` 罗勇刚(Yonggang Luo)
  0 siblings, 0 replies; 26+ messages in thread
From: 罗勇刚(Yonggang Luo) @ 2022-10-15 17:01 UTC (permalink / raw)
  To: Mark Wielaard; +Cc: elfutils-devel

[-- Attachment #1: Type: text/plain, Size: 762 bytes --]

OK, updated in v2

On Sat, Oct 15, 2022 at 5:16 AM Mark Wielaard <mark@klomp.org> wrote:
>
> On Tue, Sep 20, 2022 at 04:43:02PM +0800, Yonggang Luo via Elfutils-devel
wrote:
> > All of these files either #include <system.h> directly or #include
"libelfP.h"
> > And now "libelfP.h also #include <system.h>, so the platform depended
include
> > can be moved to system.h safely
>
> I like this in theory since it cleans up some of the includes.
> But it doesn't work as is.
>
> libebl/eblobjnotetypename.c only included system.h so now doesn't
> compile anymore.  And libintl.h is removed from libelf/elf_error.c
> which really is necessary.
>
> Cheers,
>
> Mark



--
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 5/7] Strip __ prefix from __BYTE_ORDER __LITTLE_ENDIAN and __BIG_ENDIAN
  2022-09-20  8:43 ` [PATCH 5/7] Strip __ prefix from __BYTE_ORDER __LITTLE_ENDIAN and __BIG_ENDIAN Yonggang Luo
@ 2022-10-16 21:11   ` Mark Wielaard
  2022-10-17  3:40     ` 罗勇刚(Yonggang Luo)
  0 siblings, 1 reply; 26+ messages in thread
From: Mark Wielaard @ 2022-10-16 21:11 UTC (permalink / raw)
  To: Yonggang Luo; +Cc: elfutils-devel

Hi,

This seems to work and is probably OK.  But do you know when/what the
__ prefix versions are defined and when/what defines the non-prefixed
versions?

Thanks,

Mark

On Tue, Sep 20, 2022 at 04:43:05PM +0800, Yonggang Luo via Elfutils-devel wrote:
> Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
> ---
>  lib/system.h                         |  4 ++--
>  libcpu/i386_disasm.c                 |  2 +-
>  libcpu/memory-access.h               | 26 +++++++++++++-------------
>  libcpu/riscv_disasm.c                |  2 +-
>  libdw/memory-access.h                |  8 ++++----
>  libdwfl/dwfl_segment_report_module.c |  2 +-
>  libelf/common.h                      |  2 +-
>  libelf/elf32_checksum.c              |  4 ++--
>  libelf/elf32_xlatetof.c              |  4 ++--
>  libelf/elf_getarsym.c                |  6 +++---
>  src/arlib.h                          |  2 +-
>  11 files changed, 31 insertions(+), 31 deletions(-)
> 
> diff --git a/lib/system.h b/lib/system.h
> index 48004df1..bbbe06c4 100644
> --- a/lib/system.h
> +++ b/lib/system.h
> @@ -64,12 +64,12 @@ void error(int status, int errnum, const char *format, ...);
>      exit (EXIT_FAILURE); \
>    } while (0)
>  
> -#if __BYTE_ORDER == __LITTLE_ENDIAN
> +#if BYTE_ORDER == LITTLE_ENDIAN
>  # define LE32(n)	(n)
>  # define LE64(n)	(n)
>  # define BE32(n)	bswap_32 (n)
>  # define BE64(n)	bswap_64 (n)
> -#elif __BYTE_ORDER == __BIG_ENDIAN
> +#elif BYTE_ORDER == BIG_ENDIAN
>  # define BE32(n)	(n)
>  # define BE64(n)	(n)
>  # define LE32(n)	bswap_32 (n)
> diff --git a/libcpu/i386_disasm.c b/libcpu/i386_disasm.c
> index fd7340cc..40475b81 100644
> --- a/libcpu/i386_disasm.c
> +++ b/libcpu/i386_disasm.c
> @@ -44,7 +44,7 @@
>  
>  #include "../libebl/libeblP.h"
>  
> -#define MACHINE_ENCODING __LITTLE_ENDIAN
> +#define MACHINE_ENCODING LITTLE_ENDIAN
>  #include "memory-access.h"
>  
>  
> diff --git a/libcpu/memory-access.h b/libcpu/memory-access.h
> index 779825fa..3b6ca19b 100644
> --- a/libcpu/memory-access.h
> +++ b/libcpu/memory-access.h
> @@ -41,7 +41,7 @@
>  #ifndef MACHINE_ENCODING
>  # error "MACHINE_ENCODING needs to be defined"
>  #endif
> -#if MACHINE_ENCODING != __BIG_ENDIAN && MACHINE_ENCODING != __LITTLE_ENDIAN
> +#if MACHINE_ENCODING != BIG_ENDIAN && MACHINE_ENCODING != LITTLE_ENDIAN
>  # error "MACHINE_ENCODING must signal either big or little endian"
>  #endif
>  
> @@ -51,31 +51,31 @@
>  #if ALLOW_UNALIGNED
>  
>  # define read_2ubyte_unaligned(Addr) \
> -  (unlikely (MACHINE_ENCODING != __BYTE_ORDER)				      \
> +  (unlikely (MACHINE_ENCODING != BYTE_ORDER)				      \
>     ? bswap_16 (*((const uint16_t *) (Addr)))				      \
>     : *((const uint16_t *) (Addr)))
>  # define read_2sbyte_unaligned(Addr) \
> -  (unlikely (MACHINE_ENCODING != __BYTE_ORDER)				      \
> +  (unlikely (MACHINE_ENCODING != BYTE_ORDER)				      \
>     ? (int16_t) bswap_16 (*((const int16_t *) (Addr)))			      \
>     : *((const int16_t *) (Addr)))
>  
>  # define read_4ubyte_unaligned_noncvt(Addr) \
>     *((const uint32_t *) (Addr))
>  # define read_4ubyte_unaligned(Addr) \
> -  (unlikely (MACHINE_ENCODING != __BYTE_ORDER)				      \
> +  (unlikely (MACHINE_ENCODING != BYTE_ORDER)				      \
>     ? bswap_32 (*((const uint32_t *) (Addr)))				      \
>     : *((const uint32_t *) (Addr)))
>  # define read_4sbyte_unaligned(Addr) \
> -  (unlikely (MACHINE_ENCODING != __BYTE_ORDER)				      \
> +  (unlikely (MACHINE_ENCODING != BYTE_ORDER)				      \
>     ? (int32_t) bswap_32 (*((const int32_t *) (Addr)))			      \
>     : *((const int32_t *) (Addr)))
>  
>  # define read_8ubyte_unaligned(Addr) \
> -  (unlikely (MACHINE_ENCODING != __BYTE_ORDER)				      \
> +  (unlikely (MACHINE_ENCODING != BYTE_ORDER)				      \
>     ? bswap_64 (*((const uint64_t *) (Addr)))				      \
>     : *((const uint64_t *) (Addr)))
>  # define read_8sbyte_unaligned(Addr) \
> -  (unlikely (MACHINE_ENCODING != __BYTE_ORDER)				      \
> +  (unlikely (MACHINE_ENCODING != BYTE_ORDER)				      \
>     ? (int64_t) bswap_64 (*((const int64_t *) (Addr)))			      \
>     : *((const int64_t *) (Addr)))
>  
> @@ -96,7 +96,7 @@ static inline uint16_t
>  read_2ubyte_unaligned (const void *p)
>  {
>    const union unaligned *up = p;
> -  if (MACHINE_ENCODING != __BYTE_ORDER)
> +  if (MACHINE_ENCODING != BYTE_ORDER)
>      return bswap_16 (up->u2);
>    return up->u2;
>  }
> @@ -104,7 +104,7 @@ static inline int16_t
>  read_2sbyte_unaligned (const void *p)
>  {
>    const union unaligned *up = p;
> -  if (MACHINE_ENCODING != __BYTE_ORDER)
> +  if (MACHINE_ENCODING != BYTE_ORDER)
>      return (int16_t) bswap_16 (up->u2);
>    return up->s2;
>  }
> @@ -119,7 +119,7 @@ static inline uint32_t
>  read_4ubyte_unaligned (const void *p)
>  {
>    const union unaligned *up = p;
> -  if (MACHINE_ENCODING != __BYTE_ORDER)
> +  if (MACHINE_ENCODING != BYTE_ORDER)
>      return bswap_32 (up->u4);
>    return up->u4;
>  }
> @@ -127,7 +127,7 @@ static inline int32_t
>  read_4sbyte_unaligned (const void *p)
>  {
>    const union unaligned *up = p;
> -  if (MACHINE_ENCODING != __BYTE_ORDER)
> +  if (MACHINE_ENCODING != BYTE_ORDER)
>      return (int32_t) bswap_32 (up->u4);
>    return up->s4;
>  }
> @@ -136,7 +136,7 @@ static inline uint64_t
>  read_8ubyte_unaligned (const void *p)
>  {
>    const union unaligned *up = p;
> -  if (MACHINE_ENCODING != __BYTE_ORDER)
> +  if (MACHINE_ENCODING != BYTE_ORDER)
>      return bswap_64 (up->u8);
>    return up->u8;
>  }
> @@ -144,7 +144,7 @@ static inline int64_t
>  read_8sbyte_unaligned (const void *p)
>  {
>    const union unaligned *up = p;
> -  if (MACHINE_ENCODING != __BYTE_ORDER)
> +  if (MACHINE_ENCODING != BYTE_ORDER)
>      return (int64_t) bswap_64 (up->u8);
>    return up->s8;
>  }
> diff --git a/libcpu/riscv_disasm.c b/libcpu/riscv_disasm.c
> index bc0d8f37..7175c077 100644
> --- a/libcpu/riscv_disasm.c
> +++ b/libcpu/riscv_disasm.c
> @@ -41,7 +41,7 @@
>  
>  #include "../libebl/libeblP.h"
>  
> -#define MACHINE_ENCODING __LITTLE_ENDIAN
> +#define MACHINE_ENCODING LITTLE_ENDIAN
>  #include "memory-access.h"
>  
>  
> diff --git a/libdw/memory-access.h b/libdw/memory-access.h
> index 8b2386ee..800b517c 100644
> --- a/libdw/memory-access.h
> +++ b/libdw/memory-access.h
> @@ -355,10 +355,10 @@ read_8sbyte_unaligned_1 (bool other_byte_order, const void *p)
>  static inline int
>  file_byte_order (bool other_byte_order)
>  {
> -#if __BYTE_ORDER == __LITTLE_ENDIAN
> -  return other_byte_order ? __BIG_ENDIAN : __LITTLE_ENDIAN;
> +#if BYTE_ORDER == LITTLE_ENDIAN
> +  return other_byte_order ? BIG_ENDIAN : LITTLE_ENDIAN;
>  #else
> -  return other_byte_order ? __LITTLE_ENDIAN : __BIG_ENDIAN;
> +  return other_byte_order ? LITTLE_ENDIAN : BIG_ENDIAN;
>  #endif
>  }
>  
> @@ -372,7 +372,7 @@ read_3ubyte_unaligned (Dwarf *dbg, const unsigned char *p)
>    } d;
>    bool other_byte_order = dbg->other_byte_order;
>  
> -  if (file_byte_order (other_byte_order) == __BIG_ENDIAN)
> +  if (file_byte_order (other_byte_order) == BIG_ENDIAN)
>      {
>        d.c[0] = 0x00;
>        d.c[1] = p[0];
> diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c
> index 1461ae26..28f87f10 100644
> --- a/libdwfl/dwfl_segment_report_module.c
> +++ b/libdwfl/dwfl_segment_report_module.c
> @@ -49,7 +49,7 @@
>  
>  #define INITIAL_READ	1024
>  
> -#if __BYTE_ORDER == __LITTLE_ENDIAN
> +#if BYTE_ORDER == LITTLE_ENDIAN
>  # define MY_ELFDATA	ELFDATA2LSB
>  #else
>  # define MY_ELFDATA	ELFDATA2MSB
> diff --git a/libelf/common.h b/libelf/common.h
> index 4561854f..9b2a856d 100644
> --- a/libelf/common.h
> +++ b/libelf/common.h
> @@ -151,7 +151,7 @@ libelf_release_all (Elf *elf)
>  		 : bswap_64 (Var))))
>  
>  
> -#if __BYTE_ORDER == __LITTLE_ENDIAN
> +#if BYTE_ORDER == LITTLE_ENDIAN
>  # define MY_ELFDATA	ELFDATA2LSB
>  #else
>  # define MY_ELFDATA	ELFDATA2MSB
> diff --git a/libelf/elf32_checksum.c b/libelf/elf32_checksum.c
> index 521668a7..a47b307d 100644
> --- a/libelf/elf32_checksum.c
> +++ b/libelf/elf32_checksum.c
> @@ -73,9 +73,9 @@ elfw2(LIBELFBITS,checksum) (Elf *elf)
>       is the same.  */
>    ident = elf->state.ELFW(elf,LIBELFBITS).ehdr->e_ident;
>    same_byte_order = ((ident[EI_DATA] == ELFDATA2LSB
> -		      && __BYTE_ORDER == __LITTLE_ENDIAN)
> +		      && BYTE_ORDER == LITTLE_ENDIAN)
>  		     || (ident[EI_DATA] == ELFDATA2MSB
> -			 && __BYTE_ORDER == __BIG_ENDIAN));
> +			 && BYTE_ORDER == BIG_ENDIAN));
>  
>    /* If we don't have native byte order, we will likely need to
>       convert the data with xlate functions.  We do it upfront instead
> diff --git a/libelf/elf32_xlatetof.c b/libelf/elf32_xlatetof.c
> index 377659c8..ab857409 100644
> --- a/libelf/elf32_xlatetof.c
> +++ b/libelf/elf32_xlatetof.c
> @@ -82,8 +82,8 @@ elfw2(LIBELFBITS, xlatetof) (Elf_Data *dest, const Elf_Data *src,
>  	and vice versa since the function only has to copy and/or
>  	change the byte order.
>    */
> -  if ((__BYTE_ORDER == __LITTLE_ENDIAN && encode == ELFDATA2LSB)
> -      || (__BYTE_ORDER == __BIG_ENDIAN && encode == ELFDATA2MSB))
> +  if ((BYTE_ORDER == LITTLE_ENDIAN && encode == ELFDATA2LSB)
> +      || (BYTE_ORDER == BIG_ENDIAN && encode == ELFDATA2MSB))
>      {
>        /* We simply have to copy since the byte order is the same.  */
>        if (src->d_buf != dest->d_buf)
> diff --git a/libelf/elf_getarsym.c b/libelf/elf_getarsym.c
> index 2203521f..281f0c1c 100644
> --- a/libelf/elf_getarsym.c
> +++ b/libelf/elf_getarsym.c
> @@ -61,7 +61,7 @@ read_number_entries (uint64_t *nump, Elf *elf, size_t *offp, bool index64_p)
>  
>    *offp += w;
>  
> -  if (__BYTE_ORDER == __LITTLE_ENDIAN)
> +  if (BYTE_ORDER == LITTLE_ENDIAN)
>      *nump = index64_p ? bswap_64 (u.ret64) : bswap_32 (u.ret32);
>    else
>      *nump = index64_p ? u.ret64 : u.ret32;
> @@ -266,7 +266,7 @@ elf_getarsym (Elf *elf, size_t *ptr)
>  	      if (index64_p)
>  		{
>  		  uint64_t tmp = (*u64)[cnt];
> -		  if (__BYTE_ORDER == __LITTLE_ENDIAN)
> +		  if (BYTE_ORDER == LITTLE_ENDIAN)
>  		    tmp = bswap_64 (tmp);
>  
>  		  arsym[cnt].as_off = tmp;
> @@ -286,7 +286,7 @@ elf_getarsym (Elf *elf, size_t *ptr)
>  		      goto out;
>  		    }
>  		}
> -	      else if (__BYTE_ORDER == __LITTLE_ENDIAN)
> +	      else if (BYTE_ORDER == LITTLE_ENDIAN)
>  		arsym[cnt].as_off = bswap_32 ((*u32)[cnt]);
>  	      else
>  		arsym[cnt].as_off = (*u32)[cnt];
> diff --git a/src/arlib.h b/src/arlib.h
> index e117166e..d4a42210 100644
> --- a/src/arlib.h
> +++ b/src/arlib.h
> @@ -46,7 +46,7 @@ extern const struct argp_child arlib_argp_children[];
>  #define AR_HDR_WORDS (sizeof (struct ar_hdr) / sizeof (uint32_t))
>  
>  
> -#if __BYTE_ORDER == __LITTLE_ENDIAN
> +#if BYTE_ORDER == LITTLE_ENDIAN
>  # define le_bswap_32(val) bswap_32 (val)
>  #else
>  # define le_bswap_32(val) (val)
> -- 
> 2.36.1.windows.1
> 

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 6/7] Fixes building with msvc/clang mingw/gcc
  2022-09-20  8:43 ` [PATCH 6/7] Fixes building with msvc/clang mingw/gcc Yonggang Luo
@ 2022-10-16 21:21   ` Mark Wielaard
  2022-12-16 21:12     ` 罗勇刚(Yonggang Luo)
  0 siblings, 1 reply; 26+ messages in thread
From: Mark Wielaard @ 2022-10-16 21:21 UTC (permalink / raw)
  To: Yonggang Luo; +Cc: elfutils-devel

Hi,

I find this hard to review. I have no experienc with msvc and don't
know when/what _MSC_VER implies or how to verify system_win32.c. I am
also a bit worried that the various ifdefs will be hard to keep
correct.

If we don't have HAVE_DECL_MMAP does the testsuite still work?

Maybe this patch can be split up is separate concerns. But I have to
admit I am a litle afraid this will be hard to keep working.

Cheers,

Mark

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 7/7] Add CMake build files
  2022-09-20  8:43 ` [PATCH 7/7] Add CMake build files Yonggang Luo
@ 2022-10-16 21:23   ` Mark Wielaard
  2022-12-16 21:12     ` 罗勇刚(Yonggang Luo)
  0 siblings, 1 reply; 26+ messages in thread
From: Mark Wielaard @ 2022-10-16 21:23 UTC (permalink / raw)
  To: Yonggang Luo; +Cc: elfutils-devel

Hi,

I rather not have multiple build systems in the tree. Are the
autotools not available on your system?

Cheers,

Mark

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 5/7] Strip __ prefix from __BYTE_ORDER __LITTLE_ENDIAN and __BIG_ENDIAN
  2022-10-16 21:11   ` Mark Wielaard
@ 2022-10-17  3:40     ` 罗勇刚(Yonggang Luo)
  2022-10-17  8:42       ` Mark Wielaard
  0 siblings, 1 reply; 26+ messages in thread
From: 罗勇刚(Yonggang Luo) @ 2022-10-17  3:40 UTC (permalink / raw)
  To: Mark Wielaard; +Cc: elfutils-devel

[-- Attachment #1: Type: text/plain, Size: 415 bytes --]

On Mon, Oct 17, 2022 at 5:11 AM Mark Wielaard <mark@klomp.org> wrote:
>
> Hi,
>
> This seems to work and is probably OK.  But do you know when/what the
> __ prefix versions are defined and when/what defines the non-prefixed
> versions?
>

__BYTE_ORDER__ is a predefined macro by gcc/clang,

BYTE_ORDER is defined in <endian.h>

--
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 5/7] Strip __ prefix from __BYTE_ORDER __LITTLE_ENDIAN and __BIG_ENDIAN
  2022-10-17  3:40     ` 罗勇刚(Yonggang Luo)
@ 2022-10-17  8:42       ` Mark Wielaard
  0 siblings, 0 replies; 26+ messages in thread
From: Mark Wielaard @ 2022-10-17  8:42 UTC (permalink / raw)
  To: 罗勇刚(Yonggang Luo); +Cc: elfutils-devel

Hi,

On Mon, Oct 17, 2022 at 11:40:11AM +0800, 罗勇刚(Yonggang Luo) wrote:
> > This seems to work and is probably OK.  But do you know when/what the
> > __ prefix versions are defined and when/what defines the non-prefixed
> > versions?
> 
> __BYTE_ORDER__ is a predefined macro by gcc/clang,
> 
> BYTE_ORDER is defined in <endian.h>

Aha, thanks. I added that to the commit message and pushed the change.

Cheers,

Mark

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 1/7] Rename 'hello2.spec.' -> 'hello2.spec' 'hello3.spec.' -> 'hello3.spec'
  2022-10-14 20:35   ` Mark Wielaard
@ 2022-10-19 18:45     ` 罗勇刚(Yonggang Luo)
  2022-10-19 19:49       ` Frank Ch. Eigler
  0 siblings, 1 reply; 26+ messages in thread
From: 罗勇刚(Yonggang Luo) @ 2022-10-19 18:45 UTC (permalink / raw)
  To: Mark Wielaard; +Cc: elfutils-devel

[-- Attachment #1: Type: text/plain, Size: 2382 bytes --]

I really want this to be merged :) ping Frank,
as this would stop me clone elfutils on windows

On Sat, Oct 15, 2022 at 4:35 AM Mark Wielaard <mark@klomp.org> wrote:
>
> Hi,
>
> On Tue, Sep 20, 2022 at 04:43:01PM +0800, Yonggang Luo via Elfutils-devel
wrote:
> > These filenames are invalid on win32
>
> This looks ok to me, but I don't really know why these files were
> named this way in the first place.
>
> The files themselves are not directly used, they are there to recreate
> the hello3*rpm test files.
>
> Frank, would you mind if these are just renamed to normal *.spec?
>
> Thanks,
>
> Mark
>
> > Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
> > ---
> >  tests/Makefile.am                                   | 2 +-
> >  tests/debuginfod-rpms/{hello2.spec. => hello2.spec} | 0
> >  tests/debuginfod-rpms/{hello3.spec. => hello3.spec} | 0
> >  3 files changed, 1 insertion(+), 1 deletion(-)
> >  rename tests/debuginfod-rpms/{hello2.spec. => hello2.spec} (100%)
> >  rename tests/debuginfod-rpms/{hello3.spec. => hello3.spec} (100%)
> >
> > diff --git a/tests/Makefile.am b/tests/Makefile.am
> > index 85514898..fc2235f4 100644
> > --- a/tests/Makefile.am
> > +++ b/tests/Makefile.am
> > @@ -563,7 +563,7 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh
run-ar.sh \
> >            debuginfod-rpms/fedora31/hello3-debugsource-1.0-2.x86_64.rpm
\
> >            debuginfod-rpms/fedora31/hello3-two-1.0-2.x86_64.rpm \
> >
 debuginfod-rpms/fedora31/hello3-two-debuginfo-1.0-2.x86_64.rpm \
> > -          debuginfod-rpms/hello2.spec. \
> > +          debuginfod-rpms/hello2.spec \
> >            debuginfod-rpms/rhel6/hello2-1.0-2.i686.rpm \
> >            debuginfod-rpms/rhel6/hello2-1.0-2.src.rpm \
> >            debuginfod-rpms/rhel6/hello2-debuginfo-1.0-2.i686.rpm \
> > diff --git a/tests/debuginfod-rpms/hello2.spec.
b/tests/debuginfod-rpms/hello2.spec
> > similarity index 100%
> > rename from tests/debuginfod-rpms/hello2.spec.
> > rename to tests/debuginfod-rpms/hello2.spec
> > diff --git a/tests/debuginfod-rpms/hello3.spec.
b/tests/debuginfod-rpms/hello3.spec
> > similarity index 100%
> > rename from tests/debuginfod-rpms/hello3.spec.
> > rename to tests/debuginfod-rpms/hello3.spec
> > --
> > 2.36.1.windows.1
> >



--
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 1/7] Rename 'hello2.spec.' -> 'hello2.spec' 'hello3.spec.' -> 'hello3.spec'
  2022-10-19 18:45     ` 罗勇刚(Yonggang Luo)
@ 2022-10-19 19:49       ` Frank Ch. Eigler
  2022-10-19 21:23         ` 罗勇刚(Yonggang Luo)
                           ` (2 more replies)
  0 siblings, 3 replies; 26+ messages in thread
From: Frank Ch. Eigler @ 2022-10-19 19:49 UTC (permalink / raw)
  To: luoyonggang; +Cc: Mark Wielaard, elfutils-devel

Hi -

> I really want this to be merged :) ping Frank,
> as this would stop me clone elfutils on windows

If it doesn't break "make rpm" (or at least rpm -ts elfutils*.tar.bz2),
it's fine.  But I don't understand the problem - my windows machines have
no problem with files named "hello2.spec2." with two periods.

- FChE


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 1/7] Rename 'hello2.spec.' -> 'hello2.spec' 'hello3.spec.' -> 'hello3.spec'
  2022-10-19 19:49       ` Frank Ch. Eigler
@ 2022-10-19 21:23         ` 罗勇刚(Yonggang Luo)
  2022-10-19 21:27         ` 罗勇刚(Yonggang Luo)
  2022-10-20 16:07         ` Mark Wielaard
  2 siblings, 0 replies; 26+ messages in thread
From: 罗勇刚(Yonggang Luo) @ 2022-10-19 21:23 UTC (permalink / raw)
  To: Frank Ch. Eigler; +Cc: Mark Wielaard, elfutils-devel

[-- Attachment #1: Type: text/plain, Size: 579 bytes --]

On Thu, Oct 20, 2022 at 3:49 AM Frank Ch. Eigler <fche@redhat.com> wrote:
>
> Hi -
>
> > I really want this to be merged :) ping Frank,
> > as this would stop me clone elfutils on windows
>
> If it doesn't break "make rpm" (or at least rpm -ts elfutils*.tar.bz2),
> it's fine.  But I don't understand the problem - my windows machines have
> no problem with files named "hello2.spec2." with two periods.
>
Hi, Frank, `git clone` can not checkout the file, I didn't know why

> - FChE
>


--
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 1/7] Rename 'hello2.spec.' -> 'hello2.spec' 'hello3.spec.' -> 'hello3.spec'
  2022-10-19 19:49       ` Frank Ch. Eigler
  2022-10-19 21:23         ` 罗勇刚(Yonggang Luo)
@ 2022-10-19 21:27         ` 罗勇刚(Yonggang Luo)
  2022-10-21 15:45           ` Frank Ch. Eigler
  2022-10-20 16:07         ` Mark Wielaard
  2 siblings, 1 reply; 26+ messages in thread
From: 罗勇刚(Yonggang Luo) @ 2022-10-19 21:27 UTC (permalink / raw)
  To: Frank Ch. Eigler; +Cc: Mark Wielaard, elfutils-devel

[-- Attachment #1: Type: text/plain, Size: 653 bytes --]

> If it doesn't break "make rpm" (or at least rpm -ts elfutils*.tar.bz2),
> it's fine.  But I don't understand the problem - my windows machines have
> no problem with files named "hello2.spec2." with two periods.
>
> - FChE

This is the error log:
```
C:\Users\lygstate>cd /d C:\work\xemu\elfutils

C:\work\xemu\elfutils>git reset --hard
4cc429d2761846967678fb8cf5868d311d1f7862
error: invalid path 'tests/debuginfod-rpms/hello2.spec.'
fatal: Could not reset index file to revision
'4cc429d2761846967678fb8cf5868d311d1f7862'.

C:\work\xemu\elfutils>
```



--
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 1/7] Rename 'hello2.spec.' -> 'hello2.spec' 'hello3.spec.' -> 'hello3.spec'
  2022-10-19 19:49       ` Frank Ch. Eigler
  2022-10-19 21:23         ` 罗勇刚(Yonggang Luo)
  2022-10-19 21:27         ` 罗勇刚(Yonggang Luo)
@ 2022-10-20 16:07         ` Mark Wielaard
  2022-10-31 13:29           ` Mark Wielaard
  2 siblings, 1 reply; 26+ messages in thread
From: Mark Wielaard @ 2022-10-20 16:07 UTC (permalink / raw)
  To: Frank Ch. Eigler, luoyonggang; +Cc: elfutils-devel

[-- Attachment #1: Type: text/plain, Size: 1059 bytes --]

Hi,

On Wed, 2022-10-19 at 15:49 -0400, Frank Ch. Eigler via Elfutils-devel
wrote:
> I really want this to be merged :) ping Frank,
> > as this would stop me clone elfutils on windows
> 
> If it doesn't break "make rpm" (or at least rpm -ts
> elfutils*.tar.bz2),
> it's fine.

make rpm doesn't work because of:

rpmbuild -ts --sign elfutils-0.187.tar.bz2
error: rpmbuild --sign is no longer supported. Use the rpmsign command
instead!
make: *** [Makefile:971: rpm] Error 1

Maybe just remove the --sign?

But then, with the rename, you'll get:

rpmbuild -ts elfutils-0.187.tar.bz2
error: Found more than one spec file in elfutils-0.187.tar.bz2
make: *** [Makefile:971: rpm] Error 1

So maybe we just should rename them to .specfile?
That is what the attached patch does, plus some other cleanups.
- We forgot to include the hello3.specfile
- Remove the --sign from rpmbuild
- escape the % in spec comments

That makes make rpm work out of the box without warnings.
Does it also help the windows git thing?

Cheers,

Mark

[-- Attachment #2: 0001-Rename-hello-2-3-.spec.-hello-2-3-.specfile.patch --]
[-- Type: text/x-patch, Size: 4710 bytes --]

From f7bd331326a03108095b7593bb48d7482690501f Mon Sep 17 00:00:00 2001
From: Yonggang Luo <luoyonggang@gmail.com>
Date: Tue, 20 Sep 2022 16:43:01 +0800
Subject: [PATCH] Rename 'hello{2,3}.spec.' -> 'hello{2,3}.specfile'

These filenames are invalid on win32.
We don't want to include multiple .spec files for make rpm.
rpmbuild --sign is not supported anymore.
Also include hello3.specfile in EXTRA_DIST.
Escape some macros in the elfutils.spec.in file comments.

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Signed-off-by: Mark Wielaard <mark@klomp.org>
---
 ChangeLog                                               | 4 ++++
 Makefile.am                                             | 2 +-
 config/ChangeLog                                        | 4 ++++
 config/elfutils.spec.in                                 | 6 +++---
 tests/ChangeLog                                         | 9 +++++++++
 tests/Makefile.am                                       | 3 ++-
 tests/debuginfod-rpms/{hello2.spec. => hello2.specfile} | 0
 tests/debuginfod-rpms/{hello3.spec. => hello3.specfile} | 0
 8 files changed, 23 insertions(+), 5 deletions(-)
 rename tests/debuginfod-rpms/{hello2.spec. => hello2.specfile} (100%)
 rename tests/debuginfod-rpms/{hello3.spec. => hello3.specfile} (100%)

diff --git a/ChangeLog b/ChangeLog
index 60624183..2bf99c71 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2022-10-20  Mark Wielaard  <mark@klomp.org>
+
+	* Makefile.am (rpm): Remove --sign.
+
 2022-09-13  Aleksei Vetrov  <vvvvvv@google.com>
 
 	* NEWS (libdwfl): Add dwfl_report_offline_memory.
diff --git a/Makefile.am b/Makefile.am
index 8643312a..e92e05c2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -44,7 +44,7 @@ distcheck-hook:
 	chmod -R u+w $(distdir)
 
 rpm: dist
-	rpmbuild -ts --sign elfutils-@PACKAGE_VERSION@.tar.bz2
+	rpmbuild -ts elfutils-@PACKAGE_VERSION@.tar.bz2
 
 if GCOV
 
diff --git a/config/ChangeLog b/config/ChangeLog
index 1265f399..4c7164e5 100644
--- a/config/ChangeLog
+++ b/config/ChangeLog
@@ -1,3 +1,7 @@
+2022-10-20  Mark Wielaard  <mark@klomp.org>
+
+	* elfutils.spec.in: Escape % in comments.
+
 2022-08-17  Martin Liska  <mliska@suse.cz>
 
 	* debuginfod.service: Add new debuginfod.sysconfig
diff --git a/config/elfutils.spec.in b/config/elfutils.spec.in
index 54599159..3282de26 100644
--- a/config/elfutils.spec.in
+++ b/config/elfutils.spec.in
@@ -263,18 +263,18 @@ fi
 %dir %{_includedir}/elfutils
 %{_includedir}/elfutils/elf-knowledge.h
 %{_includedir}/elfutils/known-dwarf.h
-#%{_includedir}/elfutils/libasm.h
+#%%{_includedir}/elfutils/libasm.h
 %{_includedir}/elfutils/libdw.h
 %{_includedir}/elfutils/libdwfl.h
 %{_includedir}/elfutils/libdwelf.h
 %{_includedir}/elfutils/version.h
-#%{_libdir}/libasm.so
+#%%{_libdir}/libasm.so
 %{_libdir}/libdw.so
 %{_libdir}/pkgconfig/libdw.pc
 
 %files devel-static
 %{_libdir}/libdw.a
-#%{_libdir}/libasm.a
+#%%{_libdir}/libasm.a
 
 %files libelf
 %license COPYING-GPLV2 COPYING-LGPLV3
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 0ea1df3d..31f4d0e4 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,12 @@
+2022-09-20  Yonggang Luo  <luoyonggang@gmail.com>
+
+	* Makefile.am (EXTRA_DIST): Remove debuginfod-rpms/hello2.spec.
+	Add debuginfod-rpms/hello{2,3}.specfile.
+	* tests/debuginfod-rpms/hello2.spec.: Renamed to...
+	* tests/debuginfod-rpms/hello2.specfile: ...this.
+	* tests/debuginfod-rpms/hello3.spec.: Renamed to...
+	* tests/debuginfod-rpms/hello3.specfile: ...this.
+
 2022-10-16  Mark Wielaard  <mark@klomp.org>
 
 	* dwfl-report-offline-memory.c: Include config.h first.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index f680d3e1..ced4a826 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -566,7 +566,8 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh run-ar.sh \
 	     debuginfod-rpms/fedora31/hello3-debugsource-1.0-2.x86_64.rpm \
 	     debuginfod-rpms/fedora31/hello3-two-1.0-2.x86_64.rpm \
 	     debuginfod-rpms/fedora31/hello3-two-debuginfo-1.0-2.x86_64.rpm \
-	     debuginfod-rpms/hello2.spec. \
+	     debuginfod-rpms/hello2.specfile \
+	     debuginfod-rpms/hello3.specfile \
 	     debuginfod-rpms/rhel6/hello2-1.0-2.i686.rpm \
 	     debuginfod-rpms/rhel6/hello2-1.0-2.src.rpm \
 	     debuginfod-rpms/rhel6/hello2-debuginfo-1.0-2.i686.rpm \
diff --git a/tests/debuginfod-rpms/hello2.spec. b/tests/debuginfod-rpms/hello2.specfile
similarity index 100%
rename from tests/debuginfod-rpms/hello2.spec.
rename to tests/debuginfod-rpms/hello2.specfile
diff --git a/tests/debuginfod-rpms/hello3.spec. b/tests/debuginfod-rpms/hello3.specfile
similarity index 100%
rename from tests/debuginfod-rpms/hello3.spec.
rename to tests/debuginfod-rpms/hello3.specfile
-- 
2.18.4


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 1/7] Rename 'hello2.spec.' -> 'hello2.spec' 'hello3.spec.' -> 'hello3.spec'
  2022-10-19 21:27         ` 罗勇刚(Yonggang Luo)
@ 2022-10-21 15:45           ` Frank Ch. Eigler
  0 siblings, 0 replies; 26+ messages in thread
From: Frank Ch. Eigler @ 2022-10-21 15:45 UTC (permalink / raw)
  To: 罗勇刚(Yonggang Luo); +Cc: Mark Wielaard, elfutils-devel

Hi -

> C:\work\xemu\elfutils>git reset --hard
> 4cc429d2761846967678fb8cf5868d311d1f7862
> error: invalid path 'tests/debuginfod-rpms/hello2.spec.'
> fatal: Could not reset index file to revision
> '4cc429d2761846967678fb8cf5868d311d1f7862'.

Sounds like a git-induced problem.  Maybe try a different git client?

- FChE


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 1/7] Rename 'hello2.spec.' -> 'hello2.spec' 'hello3.spec.' -> 'hello3.spec'
  2022-10-20 16:07         ` Mark Wielaard
@ 2022-10-31 13:29           ` Mark Wielaard
  2022-11-24  8:27             ` 罗勇刚(Yonggang Luo)
  0 siblings, 1 reply; 26+ messages in thread
From: Mark Wielaard @ 2022-10-31 13:29 UTC (permalink / raw)
  To: Frank Ch. Eigler, luoyonggang; +Cc: elfutils-devel

Hi,

On Thu, 2022-10-20 at 18:07 +0200, Mark Wielaard wrote:
> So maybe we just should rename them to .specfile?
> That is what the attached patch does, plus some other cleanups.
> - We forgot to include the hello3.specfile
> - Remove the --sign from rpmbuild
> - escape the % in spec comments
> 
> That makes make rpm work out of the box without warnings.
> Does it also help the windows git thing?

I pushed this. Please let me know if it works for you.

Thanks,

Mark

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 1/7] Rename 'hello2.spec.' -> 'hello2.spec' 'hello3.spec.' -> 'hello3.spec'
  2022-10-31 13:29           ` Mark Wielaard
@ 2022-11-24  8:27             ` 罗勇刚(Yonggang Luo)
  0 siblings, 0 replies; 26+ messages in thread
From: 罗勇刚(Yonggang Luo) @ 2022-11-24  8:27 UTC (permalink / raw)
  To: Mark Wielaard; +Cc: Frank Ch. Eigler, elfutils-devel

[-- Attachment #1: Type: text/plain, Size: 699 bytes --]

Thanks, works fine

On Mon, Oct 31, 2022 at 9:29 PM Mark Wielaard <aegon@wildebeest.org> wrote:
>
> Hi,
>
> On Thu, 2022-10-20 at 18:07 +0200, Mark Wielaard wrote:
> > So maybe we just should rename them to .specfile?
> > That is what the attached patch does, plus some other cleanups.
> > - We forgot to include the hello3.specfile
> > - Remove the --sign from rpmbuild
> > - escape the % in spec comments
> >
> > That makes make rpm work out of the box without warnings.
> > Does it also help the windows git thing?
>
> I pushed this. Please let me know if it works for you.
>
> Thanks,
>
> Mark



--
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 6/7] Fixes building with msvc/clang mingw/gcc
  2022-10-16 21:21   ` Mark Wielaard
@ 2022-12-16 21:12     ` 罗勇刚(Yonggang Luo)
  0 siblings, 0 replies; 26+ messages in thread
From: 罗勇刚(Yonggang Luo) @ 2022-12-16 21:12 UTC (permalink / raw)
  To: Mark Wielaard; +Cc: elfutils-devel

[-- Attachment #1: Type: text/plain, Size: 721 bytes --]

I am not able running test-suite on windows yet, just getting it compiled
at the very first step

On Mon, Oct 17, 2022 at 5:21 AM Mark Wielaard <mark@klomp.org> wrote:
>
> Hi,
>
> I find this hard to review. I have no experienc with msvc and don't
> know when/what _MSC_VER implies or how to verify system_win32.c. I am
> also a bit worried that the various ifdefs will be hard to keep
> correct.
>
> If we don't have HAVE_DECL_MMAP does the testsuite still work?
>
> Maybe this patch can be split up is separate concerns. But I have to
> admit I am a litle afraid this will be hard to keep working.
>
> Cheers,
>
> Mark



--
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 7/7] Add CMake build files
  2022-10-16 21:23   ` Mark Wielaard
@ 2022-12-16 21:12     ` 罗勇刚(Yonggang Luo)
  0 siblings, 0 replies; 26+ messages in thread
From: 罗勇刚(Yonggang Luo) @ 2022-12-16 21:12 UTC (permalink / raw)
  To: Mark Wielaard; +Cc: elfutils-devel

[-- Attachment #1: Type: text/plain, Size: 380 bytes --]

Using cmake building with msvc-clang will be easier, anyway I'll drop it
first

On Mon, Oct 17, 2022 at 5:23 AM Mark Wielaard <mark@klomp.org> wrote:
>
> Hi,
>
> I rather not have multiple build systems in the tree. Are the
> autotools not available on your system?
>
> Cheers,
>
> Mark



--
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2022-12-16 21:13 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-20  8:43 [PATCH 0/7] Enable building libelf of elfutils on win32 Yonggang Luo
2022-09-20  8:43 ` [PATCH 1/7] Rename 'hello2.spec.' -> 'hello2.spec' 'hello3.spec.' -> 'hello3.spec' Yonggang Luo
2022-10-14 20:35   ` Mark Wielaard
2022-10-19 18:45     ` 罗勇刚(Yonggang Luo)
2022-10-19 19:49       ` Frank Ch. Eigler
2022-10-19 21:23         ` 罗勇刚(Yonggang Luo)
2022-10-19 21:27         ` 罗勇刚(Yonggang Luo)
2022-10-21 15:45           ` Frank Ch. Eigler
2022-10-20 16:07         ` Mark Wielaard
2022-10-31 13:29           ` Mark Wielaard
2022-11-24  8:27             ` 罗勇刚(Yonggang Luo)
2022-09-20  8:43 ` [PATCH 2/7] move platform depended include into system.h Yonggang Luo
2022-10-14 21:16   ` Mark Wielaard
2022-10-15 17:01     ` 罗勇刚(Yonggang Luo)
2022-09-20  8:43 ` [PATCH 3/7] lib: Use NOT_HAVE_LIBINTL to guard if need #include <libintl.h> Yonggang Luo
2022-09-20  8:43 ` [PATCH 4/7] Remove duplicated " Yonggang Luo
2022-09-20  8:43 ` [PATCH 5/7] Strip __ prefix from __BYTE_ORDER __LITTLE_ENDIAN and __BIG_ENDIAN Yonggang Luo
2022-10-16 21:11   ` Mark Wielaard
2022-10-17  3:40     ` 罗勇刚(Yonggang Luo)
2022-10-17  8:42       ` Mark Wielaard
2022-09-20  8:43 ` [PATCH 6/7] Fixes building with msvc/clang mingw/gcc Yonggang Luo
2022-10-16 21:21   ` Mark Wielaard
2022-12-16 21:12     ` 罗勇刚(Yonggang Luo)
2022-09-20  8:43 ` [PATCH 7/7] Add CMake build files Yonggang Luo
2022-10-16 21:23   ` Mark Wielaard
2022-12-16 21:12     ` 罗勇刚(Yonggang Luo)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).