kgoldman / ibmtss

This is a user space TSS for TPM 2.0. It implements the functionality equivalent to (but not API compatible with) the TCG TSS working group's ESAPI, SAPI, and TCTI API's (and perhaps more) but with a hopefully simpler interface.
Other
26 stars 13 forks source link

/usr/bin/ld: ../utils/cryptoutils.o:/opt/ibmtss2.1.1/utils/cryptoutils.c:118: multiple definition of `tssUtilsVerbose' #10

Closed belongtothenight closed 8 months ago

belongtothenight commented 9 months ago

My building system and software details are listed below.

Build command:

# Set Env Var
export TPM_INTERFACE_TYPE=socsim
export TPM_COMMAND_PORT=2321
# Clear Previous Build
cd "${ibmtss_path}/utils/"
make -f makefiletpmc clean
cd "${ibmtss_path}/utils12/"
make -f makefiletpmc clean
# Build
cd "${ibmtss_path}/utils/"
make -f makefiletpmc
cd "${ibmtss_path}/utils12/"
make -f makefiletpmc

The following issue appears when using 2023-05-03-raspios-bullseye-arm64.img.xz, but not in Ubuntu 18.04.6 VM.

/usr/bin/ld: ../utils/cryptoutils.o:/opt/ibmtss2.1.1/utils/cryptoutils.c:118: multiple definition of `tssUtilsVerbose'; nvreadvalueauth.o:/opt/ibmtss2.1.1/utils12/nvreadvalueauth.c:56: first defined here
collect2: error: ld returned 1 exit status
make: *** [makefiletpmc:175: nvreadvalueauth] Error 1

Currently, trying to downgrade to version 1.6.0 which this problem doesn't exist according to my research colleague's test on the same platform. Hope this issue can help solving this issue.

kgoldman commented 9 months ago

Thanks. I don't have a Debian to test, but I test with several Ubuntu versions and I don't see the error. Can you please try the next branch. If it's OK, I'll merge to master.

belongtothenight commented 9 months ago

Thanks. I don't have a Debian to test, but I test with several Ubuntu versions and I don't see the error. Can you please try the next branch. If it's OK, I'll merge to master.

Sure!, I will try the source code from GitHub instead of SourceForge and let you know!

belongtothenight commented 9 months ago

Build command:

# Set Env Var
export TPM_INTERFACE_TYPE=socsim
export TPM_COMMAND_PORT=2321
# Build -> SUCCESS
cd "${ibmtss_path}/utils/"
make -f makefiletpmc -j$(nproc) 2>&1 | tee ${path_of_log}
# Build -> FAIL
cd "${ibmtss_path}/utils12/"
make -f makefiletpmc -j$(nproc) 2>&1 | tee ${path_of_log}

Terminal output referes to the following files: Branch info: TSS_git_1.log Build output in directory */utils/ (SUCCESS): TSS_utils_2.log Build output in directory */utils12/ (FAIL): TSS_utils12_2.log

Build Error in directory */utils12/:

/usr/bin/gcc -DTPM_POSIX -L. -L../utils -shared -Wl,-z,now -Wl,-soname,libibmtssutils12.so.0 \
        -o libibmtssutils12.so.0.1 ekutils12.o 
/usr/bin/gcc -DTPM_POSIX -L. -L../utils -pie -Wl,-z,now -Wl,-rpath,. activateidentity.o -libmtssutils12 -libmtss -lcrypto -o activateidentity
/usr/bin/ld: cannot find -libmtssutils12
/usr/bin/gcc -DTPM_POSIX -L. -L../utils -pie -Wl,-z,now -Wl,-rpath,. createendorsementkeypair.o -libmtssutils12 -libmtss -lcrypto -o createendorsementkeypair
collect2: error: ld returned 1 exit status
make: *** [makefiletpmc:157: activateidentity] Error 1
make: *** Waiting for unfinished jobs....
/usr/bin/ld: cannot find -libmtssutils12
rm -f 
ln -sf libibmtssutils12.so.0.1 libibmtssutils12.so.0
rm -f libibmtssutils12.so
ln -sf libibmtssutils12.so.0 libibmtssutils12.so
collect2: error: ld returned 1 exit status
make: *** [makefiletpmc:159: createendorsementkeypair] Error 1
belongtothenight commented 9 months ago

Relatively same building environment (VM) can be created with this YouTube video steps: https://www.youtube.com/watch?v=85ZJj00FKe0

It's a bit out of date but still useful. The created VM can survive through system update and a few times of software building, but will eventually freeze.

kgoldman commented 9 months ago
  1. Can you please try a simple, single threaded build. When you run a multi-theaded build, the error messages interleave and I can't tell where it fails.
  2. Do you really need the TPM 1.2 experimental TSS? It's long obsolete. If you just need TPM 2.0, can you declare success and go on to application development.
  3. There seems to be some ussue with the linker path. There is a comment in the makefile about Ubuntu and the linker. See -fuse-ld=bfd. Does it help? -L. should look in the current directory. Is the .so there?
belongtothenight commented 9 months ago
  1. Can you please try a simple, single threaded build. When you run a multi-theaded build, the error messages interleave and I can't tell where it fails.

Build command:

# Set Env Var
export TPM_INTERFACE_TYPE=socsim
export TPM_COMMAND_PORT=2321
# Single threaded utils build -> SUCCESS
cd "${ibmtss_path}/utils/"
make -f makefiletpmc 2>&1 | tee ${path_of_log}
# Single threaded utils12 build -> SUCCESS
cd "${ibmtss_path}/utils12/"
make -f makefiletpmc 2>&1 | tee ${path_of_log}
# Multi-threaded utils build -> SUCCESS
cd "${ibmtss_path}/utils/"
make -f makefiletpmc -j$(nproc) 2>&1 | tee ${path_of_log}
# Multi-threaded utils12 build -> SUCCESS
cd "${ibmtss_path}/utils12/"
make -f makefiletpmc -j$(nproc) 2>&1 | tee ${path_of_log}

Terminal output referes to the following files: Branch info: origin/master Single threaded build output in directory */utils/ (SUCCESS): TSS_utils_3.log Single threaded build output in directory */utils12/ (SUCCESS): TSS_utils12_3.log Multi-threaded build output in directory */utils/ (SUCCESS): TSS_utils_4.log Multi-threaded build output in directory */utils12/ (SUCCESS): TSS_utils12_4.log

Above results are tested with latest code pulled from GitHub. However the latest release v2.2.0 (yesterday) is not presented on SourceForge, I can't test it.

Thank you for the fix and your work!!

Sorry for the late reply, I was on vocation last week for the lunar new year.

belongtothenight commented 9 months ago
2. Do you really need the TPM 1.2 experimental TSS?  It's long obsolete. If you just need TPM 2.0, can you declare success and go on to application development.

If my understanding is correct, the directory utils holds utilities for TPM 2.0; directory utils12 holds utilities for TPM 1.2; so it's completely find if I skip building process in utils12?

belongtothenight commented 9 months ago
3. There seems to be some ussue with the linker path. There is a comment in the makefile about Ubuntu and the linker.  See -fuse-ld=bfd.  Does it help?  -L. should look in the current directory.  Is the .so there?

Uncommented both makefiletpmc -fuse-ld=bfd line.

Build command:

# Set Env Var
export TPM_INTERFACE_TYPE=socsim
export TPM_COMMAND_PORT=2321
# Single threaded utils build -> SUCCESS
cd "${ibmtss_path}/utils/"
make -f makefiletpmc 2>&1 | tee ${path_of_log}
# Single threaded utils12 build -> SUCCESS
cd "${ibmtss_path}/utils12/"
make -f makefiletpmc 2>&1 | tee ${path_of_log}
# Multi-threaded utils build -> SUCCESS
cd "${ibmtss_path}/utils/"
make -f makefiletpmc -j$(nproc) 2>&1 | tee ${path_of_log}
# Multi-threaded utils12 build -> SUCCESS
cd "${ibmtss_path}/utils12/"
make -f makefiletpmc -j$(nproc) 2>&1 | tee ${path_of_log}

Terminal output referes to the following files: Branch info: origin/master Single threaded build output in directory */utils/ (SUCCESS): TSS_utils_5.log Single threaded build output in directory */utils12/ (SUCCESS): TSS_utils12_5.log Multi-threaded build output in directory */utils/ (SUCCESS): TSS_utils_6.log Multi-threaded build output in directory */utils12/ (SUCCESS): TSS_utils12_6.log

Editing the line doesn't show much difference to my case. As for the so files in the same directories, I found the following files:

$ls "${ibmtss_path}/utils" | grep .so
libibmtss.so
libibmtss.so.2
libibmtss.so.2.2
libibmtssutils.so
libibmtssutils.so.2
libibmtssutils.so.2.2
$ls "${ibmtss_path}/utils12" | grep .so
libibmtssutils12.so
libibmtssutils12.so.0
libibmtssutils12.so.0.1
kgoldman commented 8 months ago

If my understanding is correct, the directory utils holds utilities for TPM 2.0; directory utils12 holds utilities for TPM 1.2; so it's completely find if I skip building process in utils12?

Correct. The TPM 1.2 code was an experiment at a unified TSS. Use makefiletpm20 or autotools configured for TPM 2.0

kgoldman commented 8 months ago

Above results are tested with latest code pulled from GitHub. However the latest release v2.2.0 (yesterday) is not presented on SourceForge, I can't test it.

I haven't created a tar file yet but if git is working, you're done.

belongtothenight commented 8 months ago

I haven't created a tar file yet but if git is working, you're done.

May I ask roughly when will you officially release v2.2.0 on Sourceforge?

kgoldman commented 8 months ago

https://sourceforge.net/p/ibmtpm20tss/tss/ci/v2.2.0/tree/

belongtothenight commented 8 months ago

https://sourceforge.net/p/ibmtpm20tss/tss/ci/v2.2.0/tree/

Thank you!