diff mbox series

[v1] stubdom/vtpm: add extern to function declarations

Message ID 20200617060841.7241-1-olaf@aepfle.de (mailing list archive)
State New, archived
Headers show
Series [v1] stubdom/vtpm: add extern to function declarations | expand

Commit Message

Olaf Hering June 17, 2020, 6:08 a.m. UTC
Code compiled with gcc10 will not link properly due to multiple definition of the same function.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
---
 stubdom/Makefile          |  1 +
 stubdom/vtpm_extern.patch | 48 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+)
 create mode 100644 stubdom/vtpm_extern.patch

Comments

Jason Andryuk June 17, 2020, 1:35 p.m. UTC | #1
On Wed, Jun 17, 2020 at 2:10 AM Olaf Hering <olaf@aepfle.de> wrote:
>
> Code compiled with gcc10 will not link properly due to multiple definition of the same function.
>
> Signed-off-by: Olaf Hering <olaf@aepfle.de>

Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
Samuel Thibault June 17, 2020, 1:40 p.m. UTC | #2
Jason Andryuk, le mer. 17 juin 2020 09:35:52 -0400, a ecrit:
> On Wed, Jun 17, 2020 at 2:10 AM Olaf Hering <olaf@aepfle.de> wrote:
> >
> > Code compiled with gcc10 will not link properly due to multiple definition of the same function.
> >
> > Signed-off-by: Olaf Hering <olaf@aepfle.de>
> 
> Reviewed-by: Jason Andryuk <jandryuk@gmail.com>

Acked-by: Samuel Thibault <samuel.thibaut@ens-lyon.org>

Thanks!
Ian Jackson June 18, 2020, 3:56 p.m. UTC | #3
Samuel Thibault writes ("Re: [PATCH v1] stubdom/vtpm: add extern to function declarations"):
> Jason Andryuk, le mer. 17 juin 2020 09:35:52 -0400, a ecrit:
> > On Wed, Jun 17, 2020 at 2:10 AM Olaf Hering <olaf@aepfle.de> wrote:
> > >
> > > Code compiled with gcc10 will not link properly due to multiple definition of the same function.
> > >
> > > Signed-off-by: Olaf Hering <olaf@aepfle.de>
> > 
> > Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
> 
> Acked-by: Samuel Thibault <samuel.thibaut@ens-lyon.org>

Reviewed-by: Ian Jackson <ian.jackson@eu.citrix.com>

Thanks.  I have confirmed that these symbols look to be defined (in
tpm/tpm_emulator_extern.c).  So the patch is correct.

I think this is 4.14 material.  Paul ?

We should also consider it for backports.  How far back do we need
to go ?

Ian.
Paul Durrant June 18, 2020, 4:01 p.m. UTC | #4
> -----Original Message-----
> From: Ian Jackson <ian.jackson@citrix.com>
> Sent: 18 June 2020 16:56
> To: Paul Durrant <xadimgnik@gmail.com>
> Cc: Samuel Thibault <samuel.thibault@ens-lyon.org>; Jason Andryuk <jandryuk@gmail.com>; Olaf Hering
> <olaf@aepfle.de>; xen-devel <xen-devel@lists.xenproject.org>; Wei Liu <wl@xen.org>
> Subject: Re: [XEN PATCH for-4.14 v1] stubdom/vtpm: add extern to function declarations
> 
> Samuel Thibault writes ("Re: [PATCH v1] stubdom/vtpm: add extern to function declarations"):
> > Jason Andryuk, le mer. 17 juin 2020 09:35:52 -0400, a ecrit:
> > > On Wed, Jun 17, 2020 at 2:10 AM Olaf Hering <olaf@aepfle.de> wrote:
> > > >
> > > > Code compiled with gcc10 will not link properly due to multiple definition of the same function.
> > > >
> > > > Signed-off-by: Olaf Hering <olaf@aepfle.de>
> > >
> > > Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
> >
> > Acked-by: Samuel Thibault <samuel.thibaut@ens-lyon.org>
> 
> Reviewed-by: Ian Jackson <ian.jackson@eu.citrix.com>
> 
> Thanks.  I have confirmed that these symbols look to be defined (in
> tpm/tpm_emulator_extern.c).  So the patch is correct.
> 
> I think this is 4.14 material.  Paul ?

Agreed.

Release-acked-by: Paul Durrant <paul@xen.org>

> 
> We should also consider it for backports.  How far back do we need
> to go ?
> 
> Ian.
Ian Jackson June 18, 2020, 4:05 p.m. UTC | #5
Paul Durrant writes ("RE: [XEN PATCH for-4.14 v1] stubdom/vtpm: add extern to function declarations"):
> > -----Original Message-----
> > From: Ian Jackson <ian.jackson@citrix.com>
...
> > I think this is 4.14 material.  Paul ?
> 
> Agreed.
> 
> Release-acked-by: Paul Durrant <paul@xen.org>

Thanks, pushed.

Ian.
diff mbox series

Patch

diff --git a/stubdom/Makefile b/stubdom/Makefile
index 12aa211ac3..af8cde41b9 100644
--- a/stubdom/Makefile
+++ b/stubdom/Makefile
@@ -231,6 +231,7 @@  tpm_emulator-$(XEN_TARGET_ARCH): tpm_emulator-$(TPMEMU_VERSION).tar.gz
 	patch -d $@ -p1 < vtpm-cmake-Wextra.patch
 	patch -d $@ -p1 < vtpm-implicit-fallthrough.patch
 	patch -d $@ -p1 < vtpm_TPM_ChangeAuthAsymFinish.patch
+	patch -d $@ -p1 < vtpm_extern.patch
 	mkdir $@/build
 	cd $@/build; CC=${CC} $(CMAKE) .. -DCMAKE_C_FLAGS:STRING="-std=c99 -DTPM_NO_EXTERN $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -Wno-declaration-after-statement"
 	touch $@
diff --git a/stubdom/vtpm_extern.patch b/stubdom/vtpm_extern.patch
new file mode 100644
index 0000000000..5ea4023e6d
--- /dev/null
+++ b/stubdom/vtpm_extern.patch
@@ -0,0 +1,48 @@ 
+ld: /home/abuild/rpmbuild/BUILD/xen-4.8.20191211T160002.8db85532cb/non-dbg/stubdom/vtpm/vtpm.a(vtpm_cmd.o):(.bss+0x28): multiple definition of `tpm_malloc'; /home/abuild/rpmbuild/BUILD/xen-4.8.20191211T160002.8db85532cb/non-dbg/stubdom/vtpm/vtpm.a(vtpm.o):(.bss+0x728): first defined here
+--- a/tpm/tpm_emulator_extern.h
++++ b/tpm/tpm_emulator_extern.h
+@@ -29,7 +29,7 @@ enum {
+   TPM_LOG_ERROR
+ };
+ 
+-void (*tpm_log)(int priority, const char *fmt, ...);
++extern void (*tpm_log)(int priority, const char *fmt, ...);
+ 
+ #if defined(_WIN32) || defined(_WIN64)
+ #define __BFILE__ ((strrchr(__FILE__, '\\') ? : __FILE__ - 1) + 1)
+@@ -44,27 +44,27 @@ void (*tpm_log)(int priority, const char
+ #define error(fmt, ...) tpm_log(TPM_LOG_ERROR, "%s:%d: Error: " fmt "\n", \
+                                 __BFILE__, __LINE__, ## __VA_ARGS__)
+ /* initialization */
+-int (*tpm_extern_init)(void);
+-void (*tpm_extern_release)(void);
++extern int (*tpm_extern_init)(void);
++extern void (*tpm_extern_release)(void);
+ 
+ /* memory allocation */
+ 
+-void* (*tpm_malloc)(size_t size);
++extern void* (*tpm_malloc)(size_t size);
+ 
+-void (*tpm_free)(/*const*/ void *ptr);
++extern void (*tpm_free)(/*const*/ void *ptr);
+ 
+ /* random numbers */
+ 
+-void (*tpm_get_extern_random_bytes)(void *buf, size_t nbytes);
++extern void (*tpm_get_extern_random_bytes)(void *buf, size_t nbytes);
+ 
+ /* usec since last call */
+ 
+-uint64_t (*tpm_get_ticks)(void);
++extern uint64_t (*tpm_get_ticks)(void);
+ 
+ /* file handling */
+ 
+-int (*tpm_write_to_storage)(uint8_t *data, size_t data_length);
+-int (*tpm_read_from_storage)(uint8_t **data, size_t *data_length);
++extern int (*tpm_write_to_storage)(uint8_t *data, size_t data_length);
++extern int (*tpm_read_from_storage)(uint8_t **data, size_t *data_length);
+ 
+ #endif /* _TPM_EMULATOR_EXTERN_H_ */
+