elfutils: use macro for nested function

Replace the nested function lock_dup_elf with a macro to avoid
compiler errors with clang. This works in gcc because gcc supports
nested functions but clang does not.