This patch makes elfutils-0.127 use inline functions properly as per ISO C99 if __OPTIMIZE__ is set. If it is not set, ordinary functions are used instead. gcc sets __OPTIMIZE__ on optimized compiles. Obviously, a compiler implementing ISO C99 inline functions is required for the patched source to compile properly. gcc-4.3.1 works fine. diff -ur elfutils-0.127.orig/libdw/dwarf_whatattr.c elfutils-0.127/libdw/dwarf_whatattr.c --- elfutils-0.127.orig/libdw/dwarf_whatattr.c 2006-04-11 20:52:05.000000000 +0000 +++ elfutils-0.127/libdw/dwarf_whatattr.c 2008-06-24 23:45:01.000000000 +0000 @@ -56,9 +56,13 @@ #include "libdwP.h" +#ifdef __OPTIMIZE__ +extern inline unsigned int dwarf_whatattr (Dwarf_Attribute *attr); +#else /* Optimize. */ unsigned int dwarf_whatattr (attr) Dwarf_Attribute *attr; { return attr == NULL ? 0 : attr->code; } +#endif /* Optimize. */ diff -ur elfutils-0.127.orig/libdw/dwarf_whatform.c elfutils-0.127/libdw/dwarf_whatform.c --- elfutils-0.127.orig/libdw/dwarf_whatform.c 2006-04-11 20:52:05.000000000 +0000 +++ elfutils-0.127/libdw/dwarf_whatform.c 2008-06-24 23:45:01.000000000 +0000 @@ -56,9 +56,13 @@ #include "libdwP.h" +#ifdef __OPTIMIZE__ +extern inline unsigned int dwarf_whatform (Dwarf_Attribute *attr); +#else /* Optimize. */ unsigned int dwarf_whatform (attr) Dwarf_Attribute *attr; { return attr == NULL ? 0 : attr->form; } +#endif /* Optimize. */ diff -ur elfutils-0.127.orig/libdw/libdw.h elfutils-0.127/libdw/libdw.h --- elfutils-0.127.orig/libdw/libdw.h 2007-04-05 10:33:43.000000000 +0000 +++ elfutils-0.127/libdw/libdw.h 2008-06-24 23:45:01.000000000 +0000 @@ -282,11 +282,13 @@ /* Check whether given attribute has specific form. */ extern int dwarf_hasform (Dwarf_Attribute *attr, unsigned int search_form); +#ifndef __OPTIMIZE__ /* Return attribute code of given attribute. */ extern unsigned int dwarf_whatattr (Dwarf_Attribute *attr); /* Return form code of given attribute. */ extern unsigned int dwarf_whatform (Dwarf_Attribute *attr); +#endif /* !Optimize. */ /* Return string associated with given attribute. */ @@ -624,14 +626,14 @@ /* Inline optimizations. */ #ifdef __OPTIMIZE__ /* Return attribute code of given attribute. */ -extern inline unsigned int +inline unsigned int dwarf_whatattr (Dwarf_Attribute *attr) { return attr == NULL ? 0 : attr->code; } -/* Return attribute code of given attribute. */ -extern inline unsigned int +/* Return form code of given attribute. */ +inline unsigned int dwarf_whatform (Dwarf_Attribute *attr) { return attr == NULL ? 0 : attr->form; diff -ur elfutils-0.127.orig/src/ld.h elfutils-0.127/src/ld.h --- elfutils-0.127.orig/src/ld.h 2006-07-11 23:20:42.000000000 +0000 +++ elfutils-0.127/src/ld.h 2008-06-24 23:45:01.000000000 +0000 @@ -1086,8 +1086,10 @@ /* Helper functions for the architecture specific code. */ /* Checked whether the symbol is undefined and referenced from a DSO. */ +#ifndef __OPTIMIZE__ extern bool linked_from_dso_p (struct scninfo *scninfo, size_t symidx); -extern inline bool +#else /* !Optimize. */ +inline bool linked_from_dso_p (struct scninfo *scninfo, size_t symidx) { struct usedfiles *file = scninfo->fileinfo; @@ -1101,5 +1103,6 @@ return sym->defined && sym->in_dso; } +#endif /* !Optimize. */ #endif /* ld.h */ diff -ur elfutils-0.127.orig/src/ldgeneric.c elfutils-0.127/src/ldgeneric.c --- elfutils-0.127.orig/src/ldgeneric.c 2006-07-11 23:20:42.000000000 +0000 +++ elfutils-0.127/src/ldgeneric.c 2008-06-24 23:45:01.000000000 +0000 @@ -159,6 +159,9 @@ } +#ifdef __OPTIMIZE__ +extern inline bool linked_from_dso_p (struct scninfo *scninfo, size_t symidx); +#else /* Optimize. */ bool linked_from_dso_p (struct scninfo *scninfo, size_t symidx) { @@ -173,6 +176,7 @@ return sym->defined && sym->in_dso; } +#endif /* Optimize. */ /* Initialize state object. This callback function is called after the