windows patches

2017-05-04 Thread Ulf Hermann
Hi, all patches I consider suitable for upstream right now have been posted here now. With all of them applied you still don't get useful elfutils on windows, as for example the date preservation in some of the tools doesn't work. I have more patches that just blatantly drop functionality I don

[PATCH] Use trees rather than hashes in ar.c

2017-05-04 Thread Ulf Hermann
The tree functions are more widely available. Signed-off-by: Ulf Hermann --- src/ChangeLog | 4 src/ar.c | 77 ++- 2 files changed, 48 insertions(+), 33 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 332b07c..32cd

[PATCH v2] Close files before renaming or unlinking them

2017-05-04 Thread Ulf Hermann
On windows we cannot rename or unlink open files. (strip.c was missing) Signed-off-by: Ulf Hermann --- libasm/ChangeLog | 4 libasm/asm_end.c | 15 +++ src/ChangeLog| 4 src/strip.c | 5 - tests/ChangeLog | 9 + tests/newfile.c | 7 +-- test

[PATCH] Define uid_t and gid_t in system-elf-libelf-test.c if necessary

2017-05-04 Thread Ulf Hermann
elf.h does include features.h which should define those. However, on windows there is no features.h. We have the empty features.h in libgnu that depends on config.h being included before (which we can't), and the features.h in lib that is only available when installed in selfcontained mode. Therefo

dwfl_module_addrdie fails for binaries built with clang++

2017-05-04 Thread Milian Wolff
Hey all, I noticed that elfutils fails to handle clang binaries when we want to find a DIE for a certain address. I.e. dwfl_module_addrdie returns nullptr, and eu- addr2line fails to resolve inlined frames. To reproduce this: ~~~ $ cat test.cpp #include #include #include using name

[PATCH] Remove previous test files before running the next round

2017-05-04 Thread Ulf Hermann
strip explicitly creates the new files. This will not work on windows if the files already exist. Signed-off-by: Ulf Hermann --- tests/ChangeLog | 5 + tests/run-strip-reloc.sh | 2 ++ 2 files changed, 7 insertions(+) diff --git a/tests/ChangeLog b/tests/ChangeLog index f43aeba..1a

[PATCH] Correctly determine STACKCMD on windows

2017-05-04 Thread Ulf Hermann
error() will only output the file name, but with ".exe" on windows. Signed-off-by: Ulf Hermann --- tests/ChangeLog | 6 ++ tests/run-stack-d-test.sh | 5 + tests/run-stack-demangled-test.sh | 5 + tests/run-stack-i-test.sh | 5 + 4 files changed,

[PATCH] Use octal numbers rather than permission macros

2017-05-04 Thread Ulf Hermann
The permission macros are not guaranteed to be defined and the octal numbers are rather well known. Signed-off-by: Ulf Hermann --- src/ChangeLog | 7 +++ src/ar.c| 8 src/elfcompress.c | 4 ++-- src/ranlib.c| 2 +- src/strip.c | 2 +- tests/Change

[PATCH] Write to /dev/null rather than /dev/zero

2017-05-04 Thread Ulf Hermann
/dev/zero is meant for reading zeroes. /dev/null is for writing into nirvana. Signed-off-by: Ulf Hermann --- tests/ChangeLog | 4 tests/elfshphehdr.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/ChangeLog b/tests/ChangeLog index b8de138..fef6f55 100644 ---

[PATCH] Cast pid_t to int when printing it with %d

2017-05-04 Thread Ulf Hermann
On windows x86_64 pid_t is 64bit wide. We ignore the extra bits as those messages are only informational anyway. Signed-off-by: Ulf Hermann --- src/ChangeLog | 4 src/stack.c | 20 ++-- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/ChangeLog b/src/C

[PATCH] Increase stack usage limit to 512k

2017-05-04 Thread Ulf Hermann
On windows x86_64 we need more stack in some places. Signed-off-by: Ulf Hermann --- config/ChangeLog | 4 config/eu.am | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/config/ChangeLog b/config/ChangeLog index 0f240ea..642d765 100644 --- a/config/ChangeLog +++ b/

[PATCH] Provide build rules for a compatibility library

2017-05-04 Thread Ulf Hermann
We need to export open(), close(), malloc(), and free() from the C library we are using so that we can handle resources passed to and from elfutils correctly. For example, on Windows, calling free() on memory malloc()'d with a different C library will not work. In addition, having __cxa_demangle fr

[PATCH] Provide a windows-specific ORIGINDIR for eblopenbackend

2017-05-04 Thread Ulf Hermann
$ORIGIN and $LIB are not supported by all implementations of dlopen() and on windows we need backslashes as directory separators. Signed-off-by: Ulf Hermann --- libebl/ChangeLog| 5 + libebl/eblopenbackend.c | 4 2 files changed, 9 insertions(+) diff --git a/libebl/ChangeLog b/

[PATCH] Drop the trickery in printversion.h

2017-05-04 Thread Ulf Hermann
The mechanism of moving argp_program_version_hook and argp_program_bug_address to .rodata is not portable and two pointers per program are not worth the effort to make it portable. Revert the pointers to be non-const. Signed-off-by: Ulf Hermann --- lib/ChangeLog | 5 + lib/printversion

[PATCH] Close files before renaming or unlinking them

2017-05-04 Thread Ulf Hermann
On windows we cannot rename or unlink open files. Signed-off-by: Ulf Hermann --- libasm/ChangeLog | 4 libasm/asm_end.c | 15 +++ tests/ChangeLog | 9 + tests/newfile.c | 7 +-- tests/newscn.c | 3 ++- tests/update1.c | 1 + tests/update2.c | 1 + tests/u

[PATCH] Adapt debug info fstat check for windows

2017-05-04 Thread Ulf Hermann
On windows the resulting ino and dev entries are always 0, so the file would always be discarded. We apply a heuristic instead: If the ctime, mtime, mode and size of the two files are all equal then we consider them to be the same. It's exceedingly unlikely to produce two different files for which

[PATCH] Use OS-specific paths

2017-05-04 Thread Ulf Hermann
In general we need to use ';' as path separator and '\' and directory separator on windows. The shell will automatically translate paths to some extent, but we have to call "pwd -W" rather than plain "pwd" to get something useful. Signed-off-by: Ulf Hermann --- lib/ChangeLog

[PATCH] Have diff ignore line ending differences when testing

2017-05-04 Thread Ulf Hermann
This accounts for the CR/LF problem we get when producing text files on windows. Signed-off-by: Ulf Hermann --- tests/ChangeLog | 7 +++ tests/run-addr2line-test.sh | 8 tests/run-readelf-test1.sh | 2 +- tests/run-unstrip-n.sh | 2 +- tests/test-subr.sh |

[PATCH] Open files in O_BINARY

2017-05-04 Thread Ulf Hermann
If O_BINARY is not defined, define it to 0, so that the change has no effect then. Some systems have separate binary and text modes for files, and we don't want the text mode to be used. Change-Id: If7efb5bd448c2a1c7d1eb5dab276849b1b15a3ce Signed-off-by: Ulf Hermann --- lib/ChangeLog

[PATCH] Skip deleted test if fork(2) is unavailable

2017-05-04 Thread Ulf Hermann
Signed-off-by: Ulf Hermann --- ChangeLog | 4 configure.ac| 1 + tests/ChangeLog | 4 tests/deleted.c | 14 ++ 4 files changed, 23 insertions(+) diff --git a/ChangeLog b/ChangeLog index 662c633..2cf7bd6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 20

[PATCH] Avoid using err() and errx() in tests

2017-05-04 Thread Ulf Hermann
fprintf() and exit() do the same job and are portable. Signed-off-by: Ulf Hermann --- tests/ChangeLog | 6 ++ tests/allfcts.c | 46 +++--- tests/buildid.c | 6 +++--- tests/debugaltlink.c | 6 +++--- 4 files changed, 43 insertions(+),

[PATCH v2] Check for existence of GNU-style strerror_r

2017-05-04 Thread Ulf Hermann
We cannot get GNU strerror_r from gnulib. If we don't have it, we don't translate system error codes to strings in dwfl_error.c. (rebased on top of all the other patches) Signed-off-by: Ulf Hermann --- ChangeLog| 4 configure.ac | 2 ++ libdwfl/ChangeLog| 5 +

[PATCH] Skip fchown, fchmod, fadvise, fallocate if functions are unavailable

2017-05-04 Thread Ulf Hermann
If fchmod or fchown are unavailable, then the file permission model is likely to be different from what we expect there. posix_fallocate is a frather fragile affair already on linux, and not guaranteed to do anything useful. If it's not available, the result will be the same as when it's available

[PATCH] Define roundup() for strings.c if it doesn't exist

2017-05-04 Thread Ulf Hermann
Change-Id: I6ea7c1f894e89bbaaecb724473c4c00e67296f05 Signed-off-by: Ulf Hermann --- src/ChangeLog | 4 src/strings.c | 3 +++ 2 files changed, 7 insertions(+) diff --git a/src/ChangeLog b/src/ChangeLog index 64db1ca..4a32604 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +20

[PATCH] Add our own tdestroy if search.h exposes a node_t struct

2017-05-04 Thread Ulf Hermann
tdestroy is not necessarily available from search.h, but we need it. gnulib cannot help us here as it will detect search.h to be available and functional in that case. However, some search.h expose a node_t struct which can be used to implement tdestroy. If that is the case, add an implementation t

[PATCH] Check for existence of GNU-style basename()

2017-05-04 Thread Ulf Hermann
If it doesn't exist, add an implementation to libgnu.a and config.h. Signed-off-by: Ulf Hermann --- ChangeLog | 4 configure.ac | 16 +++ libgnu/ChangeLog | 6 ++ libgnu/Makefile.am| 6 +- libgnu/basename-gnu.c | 54 ++

[PATCH] Define unlocked io functions to locked ones if they are unavailable

2017-05-04 Thread Ulf Hermann
The locked IO functions will still do the job, albeit a bit slower. Signed-off-by: Ulf Hermann --- ChangeLog | 4 configure.ac| 4 lib/ChangeLog | 5 + lib/eu-config.h | 28 4 files changed, 41 insertions(+) diff --git a/ChangeLog b/Chan

[PATCH] Wrap gnulib fts_.h in fts.h

2017-05-04 Thread Ulf Hermann
For some reason gnulib calls the headers fts_.h. We need to wrap it into an actual fts.h to make it available. Signed-off-by: Ulf Hermann --- ChangeLog | 4 configure.ac | 18 +++--- libgnu/ChangeLog | 5 + libgnu/Makefile.am | 9 - libgnu/fts.in.

Re: [PATCH] Avoid double-including config.h

2017-05-04 Thread Ulf Hermann
On 05/02/2017 01:55 PM, Ulf Hermann wrote: >> Maybe we can cleanup that last >> one once we integrate gnulib (which I believe has a good/64-off_t fts.h >> already). > > gnulib is among the bad ones. Or, at least we detect it as bad. Sorry, I meant the msys fts.h. That is also the one which needs

[PATCH] Add a stdio_ext.h that defines __fsetlocking away

2017-05-04 Thread Ulf Hermann
__fsetlocking is a nice optimization, but if it's unavailable, we can do without. Signed-off-by: Ulf Hermann --- ChangeLog | 4 configure.ac | 3 +++ libgnu/ChangeLog | 5 + libgnu/Makefile.am| 9 - libgnu/stdio_ext.in.h | 35 +++

[PATCH] Add empty features.h replacement

2017-05-04 Thread Ulf Hermann
gnulib #defines all the types we need from it in config.h, so it is empty. We still need it because other files #include it. We use this for building elfutils itself. The other features.h in lib gets installed in selfcontained mode for other projects that include elfutils headers in a different env

[PATCH v2] Add a "selfcontained" mode to provide missing headers on windows

2017-05-04 Thread Ulf Hermann
With MSVC there is no features.h, uid_t, gid_t, mode_t, and pid_t are not defined and there is also no elf.h. To make it possible to build other software against libelf and libdw, install our own version of elf.h, and a bare-bones features.h that provides exactly the above declarations. The feature

[PATCH] Add ar.h for systems where it doesn't exist

2017-05-04 Thread Ulf Hermann
Signed-off-by: Ulf Hermann --- ChangeLog | 4 configure.ac | 3 +++ libgnu/ChangeLog | 5 + libgnu/Makefile.am | 9 - libgnu/ar.in.h | 59 ++ 5 files changed, 79 insertions(+), 1 deletion(-) create mode

[PATCH] Add sysconf replacement for win32

2017-05-04 Thread Ulf Hermann
We cannot get sysconf() from gnulib and the only thing we need it for is getting the page size. Therefore, of the various possible sysconf parameters we only define and implement _SC_PAGESIZE in our replacement. Signed-off-by: Ulf Hermann --- ChangeLog | 6 ++ configure.ac

[PATCH v2] Add mman.h/.c for win32

2017-05-04 Thread Ulf Hermann
We cannot get mmap() and friends from gnulib and they don't exist on windows. The functionality we need can be implemnted using native win32 functions, though. (changelog entries were missing in V1) Signed-off-by: Ulf Hermann --- ChangeLog | 4 ++ configure.ac| 7

[PATCH] Add mman.h/.c for win32

2017-05-04 Thread Ulf Hermann
We cannot get mmap() and friends from gnulib and they don't exist on windows. The functionality we need can be implemnted using native win32 functions, though. Signed-off-by: Ulf Hermann --- configure.ac| 7 +++ libgnu/Makefile.am | 17 +- libgnu/mman_win32.c | 140 +