As Petr and Mark pointed out, most nested functions in elfutils are small
inline functions that could be replaced with macros. I would be happy to help
transforming them to macros or file scope static functions.
Please take a look of the new attached
0001-Replace-inline-nested-functions-with-macros.patch,
which converted most nested functions in the src directory.
You can see that luckily clang has "statement expression",
so we can use it for functions with return values.
If that's acceptable to you, we can transform these simple cases first
and then deal with the complicated ones later.
The diff of strip.c is harder to read because the nested "relocate" function
is moved to file scope. The declaration of struct shdr_info is moved too.
The 9 local variables used by "relocate" are all passed as constants with
the help of macro pass_relocate_closure and declare_relocate_closure.
This is probably not the cleanest or fastest transformation,
but it should keep the semantics and easy enough to maintain.
Using so many outer-scope variables is the problem.
Maybe it deserves some refactoring.
Now elfutils is one of the very few packages on Android that requires gcc.
I would like to remove that gcc dependency before Android's gcc become too old and inferior to clang/llvm like on OS X.
Thanks.