[PATCH] For clang use Blocks instead of nested functions.

2015-09-04 Thread Chih-Hung Hsieh
* Clang has Blocks like closures that can serve similar purpose as the nested functions in gnu99. Syntax of Blocks is similar to nested functions that *NESTED_FUNC macro can be used for the function/block declarations. See spec in http://clang.llvm.org/docs/BlockLanguageSpec.html * Local

Re: [PATCH] Do without on-stack variable length arrays.

2015-09-04 Thread Roland McGrath
> Is there some simple way that I can test elfutils with fortify or bound > checking tools? Depending on your system and build setup, _FORTIFY_SOURCE might be the default. It's easy enough to enable it with CPPFLAGS=-D_FORTIFY_SOURCE=2 to configure AFAIK. > How about using pointers and malloc or

Re: [PATCH] Do without on-stack variable length arrays.

2015-09-04 Thread Chih-hung Hsieh
Yes, I shall correct the description. Is there some simple way that I can test elfutils with fortify or bound checking tools? How about using pointers and malloc or alloca, and indexing through the pointers? That should avoid complaints from stronger bound checkers, although static bound checking

Re: [PATCH] Do without on-stack variable length arrays.

2015-09-04 Thread Roland McGrath
This is misstated. VLAs are a standard feature. What you're avoiding here is VLA members of structs and unions, which are a GNU extension. I also don't think you're doing it the ideal way. A union of two arrays of length one is useless. It might trigger complaints from _FORTIFY_SOURCE or othe

[PATCH] Do without on-stack variable length arrays.

2015-09-04 Thread Chih-Hung Hsieh
Prepare to compile without gnu99 extension. Signed-off-by: Chih-Hung Hsieh --- libdwfl/dwfl_module_getdwarf.c | 16 libdwfl/dwfl_segment_report_module.c | 16 libdwfl/elf-from-memory.c| 8 libdwfl/link_map.c | 26 +++

[PATCH] Fix type warnings from clang compiler.

2015-09-04 Thread Chih-Hung Hsieh
* Replace K&R function definition with prototypes to match their declarations. Clang gives errors of: promoted type 'int' of K&R function parameter is not compatible with the parameter type * Add const declaration to locs, which was passed a const. Clang gives errors of: passing 'const Elf_Dat

Re: [PATCH] Replace %Z with %z.

2015-09-04 Thread Chih-hung Hsieh
I plan to submit clang required changes in multiple patches. Maybe only the last patch will enable clang in config files. The first few should introduce no regression to gcc compilation. On Fri, Sep 4, 2015 at 10:38 AM, Josh Stone wrote: > On 09/04/2015 10:13 AM, Chih-Hung Hsieh wrote: > > Clan

Re: [PATCH] Replace %Z with %z.

2015-09-04 Thread Josh Stone
On 09/04/2015 10:13 AM, Chih-Hung Hsieh wrote: > Clang compiler gives warning to non-standard format %Z. I think the change is fine -- %z is C99 and used in many places. But isn't Clang rejected by configure.ac for not supporting nested functions? Are you patching that behavior too?

[PATCH] Replace %Z with %z.

2015-09-04 Thread Chih-Hung Hsieh
Clang compiler gives warning to non-standard format %Z. Signed-off-by: Chih-Hung Hsieh --- src/elflint.c | 10 +- src/findtextrel.c | 2 +- src/ldscript.y | 2 +- src/readelf.c | 42 +- src/unstrip.c | 14 +++---

Re: Difficulties while adding local init_regs support to libebl

2015-09-04 Thread Ben Gamari
Mark Wielaard writes: > Hi Ben, > > [Maybe read it all first before trying anything. At the end I think I > got the correct solution, I start with some more cumbersome > workarounds...] > Thanks again for your response! > On Thu, 2015-09-03 at 22:10 +0200, Ben Gamari wrote: >> I now have a few p

Re: Difficulties while adding local init_regs support to libebl

2015-09-04 Thread Mark Wielaard
Hi Ben, [Maybe read it all first before trying anything. At the end I think I got the correct solution, I start with some more cumbersome workarounds...] On Thu, 2015-09-03 at 22:10 +0200, Ben Gamari wrote: > I now have a few patches [1] adding support for collecting initial > register values fro

Re: [PATCH] readelf: handle_core_item large right shift triggers undefined behaviour.

2015-09-04 Thread Mark Wielaard
On Thu, 2015-09-03 at 13:58 -0700, Roland McGrath wrote: > What about: > w >>= n % 32; > w >>= (n - (n % 32)) % 32; > ? I don't think that works. For the interesting case n == 32, you won't shift at all. Because both expressions (32 % 32) and ((32 - 0) % 32) evaluate to zero. I prefer