[v2,07/16] libdw: Fixes compile of dwarf_whatattr.c and dwarf_whatform.c
Commit Message
If __OPTIMIZE__ is defined, then compile dwarf_whatattr.c and dwarf_whatform.c
will cause symbol conflict between
dwarf_whatattr.c and libdw.h,
dwarf_whatform.c and libdw.h,
So always undefined __OPTIMIZE__ when compiling these two files
The error message is:
dwarf_whatform.c
[build] C:\work\xemu\elfutils\libdw\dwarf_whatform.c(39,1): error: redefinition of 'dwarf_whatform'
[build] dwarf_whatform (Dwarf_Attribute *attr)
[build] ^
[build] C:\work\xemu\elfutils\libdw/libdw.h(1110,1): note: previous definition is here
[build] dwarf_whatform (Dwarf_Attribute *attr)
[build] ^
[build] 1 error generated.
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
libdw/dwarf_whatattr.c | 9 ++++-----
libdw/dwarf_whatform.c | 9 ++++-----
2 files changed, 8 insertions(+), 10 deletions(-)
Comments
Hi,
On Sun, 2022-12-18 at 00:52 +0800, Yonggang Luo via Elfutils-devel
wrote:
> If __OPTIMIZE__ is defined, then compile dwarf_whatattr.c and dwarf_whatform.c
> will cause symbol conflict between
> dwarf_whatattr.c and libdw.h,
> dwarf_whatform.c and libdw.h,
>
> So always undefined __OPTIMIZE__ when compiling these two files
>
I don't think this is correct. See also the discussion around v1 of
this patch:
https://inbox.sourceware.org/elfutils-devel/0bc05adaf492c5f57b0b45f520be14b78f3fbd53.camel@klomp.org/
Cheers,
Mark
@@ -30,13 +30,12 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
-
+#ifndef __OPTIMIZE__
+#define __OPTIMIZE__
+#endif
#include <dwarf.h>
#include "libdwP.h"
unsigned int
-dwarf_whatattr (Dwarf_Attribute *attr)
-{
- return attr == NULL ? 0 : attr->code;
-}
+dwarf_whatattr (Dwarf_Attribute *attr);
@@ -30,13 +30,12 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
-
+#ifndef __OPTIMIZE__
+#define __OPTIMIZE__
+#endif
#include <dwarf.h>
#include "libdwP.h"
unsigned int
-dwarf_whatform (Dwarf_Attribute *attr)
-{
- return attr == NULL ? 0 : attr->form;
-}
+dwarf_whatform (Dwarf_Attribute *attr);
\ No newline at end of file