porting to windows

2017-04-20 Thread Ulf Hermann
I have a total of 85 patches to port elfutils to windows. I will post them all here, once I get around to write all the ChangeLog entries, but I'm fairly sure you won't like all of them. You can see them all (and also comment if you like) on the qt code review system. See https://codereview.qt

[PATCH] Include endian.h when handling BYTE_ORDER

2017-04-20 Thread Ulf Hermann
BYTE_ORDER and friends are customarily defined in endian.h. Signed-off-by: Ulf Hermann --- libdw/ChangeLog | 4 libdw/dwarf_begin_elf.c | 1 + 2 files changed, 5 insertions(+) diff --git a/libdw/ChangeLog b/libdw/ChangeLog index c9ae664..8802853 100644 --- a/libdw/ChangeLog +++ b/l

[PATCH] Add EXEEXT to gendis

2017-04-20 Thread Ulf Hermann
Otherwise the build will fail on systems that actually need file extension for executables. Signed-off-by: Ulf Hermann --- libcpu/ChangeLog | 4 libcpu/Makefile.am | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/libcpu/ChangeLog b/libcpu/ChangeLog index e59e876.

[PATCH] On elf_update, remember when we mmap()

2017-04-20 Thread Ulf Hermann
Otherwise we skip the munmap() later. This leaks resources. Signed-off-by: Ulf Hermann --- libelf/ChangeLog| 4 libelf/elf_update.c | 2 ++ 2 files changed, 6 insertions(+) diff --git a/libelf/ChangeLog b/libelf/ChangeLog index fa768f8..225c7c8 100644 --- a/libelf/ChangeLog +++ b/libel

[PATCH] Make elf section sorting more deterministic

2017-04-20 Thread Ulf Hermann
At least one test (dwfl-addr-sect) depends on the order of elf sections with equal addresses. This is not guaranteed by the code. Compare also by end address and name to tell entries apart. Signed-off-by: Ulf Hermann --- libdwfl/ChangeLog | 5 + libdwfl/derelocate.c| 17 ++

[PATCH v2] Include sys/types.h before fts.h

2017-04-20 Thread Ulf Hermann
The bad fts not only needs to be included before config.h, but also requires various special types without including sys/types.h. Change-Id: I31ac8d2aadcf7ffb3efb63583b2745991bfd6f90 Signed-off-by: Ulf Hermann --- libdwfl/ChangeLog | 4 libdwfl/linux-kernel-modules.c | 6 +-

[PATCH] Avoid signed/unsigned comparison

2017-04-20 Thread Ulf Hermann
Some compilers implicitly cast the result of uint_fast16_t * uint_fast16_t to something signed and then complain about the comparison to (unsigned) size_t. Casting phnum to size_t is a good idea anyway as 16bit multiplication can easily overflow and we are not checking for this. Signed-off-by: Ul

Re: [PATCH] Include sys/types.h before fts.h

2017-04-20 Thread Dmitry V. Levin
On Thu, Apr 20, 2017 at 03:26:47PM +0200, Ulf Hermann wrote: > The bad fts not only needs to be included before config.h, but also > requires various special types without including sys/types.h. Please do not include before unconditionally. If bad fts needs , then do it [BAD_FTS]. -- ldv si

[PATCH] Include strings.h to make ffs available

2017-04-20 Thread Ulf Hermann
We cannot rely on it to be available from any of the other headers. Signed-off-by: Ulf Hermann --- src/ChangeLog | 4 src/readelf.c | 1 + 2 files changed, 5 insertions(+) diff --git a/src/ChangeLog b/src/ChangeLog index 1521d80..cbb77fc 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1

[PATCH] Avoid double-including config.h

2017-04-20 Thread Ulf Hermann
config.h doesn't have include guards, so including it twice is bad. We deal with this by checking for PACKAGE_NAME, but only in some places. Once we start using gnulib, we will need to include config.h before any gnulib-generated headers. This is problematic if we include it transitively through ou

[PATCH] Don't look for kernel version if not running on linux

2017-04-20 Thread Ulf Hermann
We don't want to use it, even if it exists. Signed-off-by: Ulf Hermann --- libdwfl/ChangeLog | 5 + libdwfl/linux-kernel-modules.c | 4 2 files changed, 9 insertions(+) diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index de73d79..80346d5 100644 --- a/libdwfl/ChangeLog

[PATCH] Protect against integer overflow on shnum

2017-04-20 Thread Ulf Hermann
If shnum is 0, the many "shnum - 1" would result in an overflow. Check it for 0, and only subtract once, rather than on every usage. Signed-off-by: Ulf Hermann --- libdwfl/ChangeLog | 5 + libdwfl/dwfl_module_getdwarf.c | 18 ++ src/ChangeLog |

[PATCH] Use F_GETFD rather than F_GETFL to check validity of file descriptor

2017-04-20 Thread Ulf Hermann
F_GETFD is both cheaper and easier to port, and otherwise has the same effect here. Signed-off-by: Ulf Hermann --- libelf/ChangeLog | 4 libelf/elf_begin.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/libelf/ChangeLog b/libelf/ChangeLog index 23cd942..e32590a 1006

[PATCH] Make __attribute__ conditional in all installed headers

2017-04-20 Thread Ulf Hermann
__attribute__ is a GNU extension. If we want to link against the libraries using a different compiler, it needs to be disabled. It was already disabled in libdw.h, and this patch extends this to the other headers. We move the defines to libelf.h as that is included in all the others. Signed-off-by

[PATCH] Avoid YESSTR and NOSTR

2017-04-20 Thread Ulf Hermann
Those are deprecated and apparently some implementations of nl_langinfo return empty strings for them. The tests even tested for those empty strings even though the intention of the code was clearly to output "yes" or "no" there. Signed-off-by: Ulf Hermann --- src/ChangeLog |

[PATCH] Don't use comparison_fn_t

2017-04-20 Thread Ulf Hermann
Not all search.h declare it, and it is not very helpful anyway. Signed-off-by: Ulf Hermann --- libcpu/ChangeLog| 4 libcpu/i386_parse.y | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/libcpu/ChangeLog b/libcpu/ChangeLog index 79110c2..ec22dd2 100644 --- a/libcpu

[PATCH] Clean up linux-specific system includes

2017-04-20 Thread Ulf Hermann
We only include them where we actually need them and only on linux. Change-Id: Ic3065ffab67ba1177f63204fb91a92c5f4336dbb Signed-off-by: Ulf Hermann --- backends/ChangeLog | 8 backends/aarch64_initreg.c | 4 ++-- backends/arm_initreg.c | 4 +++- backends/ppc_initreg.c |

[PATCH] Include sys/types.h before fts.h

2017-04-20 Thread Ulf Hermann
The bad fts not only needs to be included before config.h, but also requires various special types without including sys/types.h. Signed-off-by: Ulf Hermann --- libdwfl/ChangeLog | 4 libdwfl/linux-kernel-modules.c | 4 2 files changed, 8 insertions(+) diff --git a/libdwf

[PATCH v2] Add frame pointer unwinding for aarch64

2017-04-20 Thread Ulf Hermann
If we don't find any debug information for a given frame, we usually cannot unwind any further. However, the binary in question might have been compiled with frame pointers, in which case we can look up the well known frame pointer locations in the stack snapshot and use them to bridge the frames w

Re: frame unwinding patches

2017-04-20 Thread Ulf Hermann
> That might just mean that the testcase is slightly unrealistic. > Getting a reliable backtrace through signal handlers when not having > full CFI is probably not something we can expect to work. That doesn't > mean having a frame pointer based fallback is a bad thing. We probably > should find a