Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hack to 'fix' Issue #135 for acipher-rs TA #138

Draft
wants to merge 1 commit into
base: no-std
Choose a base branch
from

Conversation

msgilligan
Copy link
Contributor

This is a "hack" which demonstrates changes that I made that eliminate the error seen in Issue #135. I don't understand the compile/link process well enough to submit a real fix and I haven't even tested that the build of this TA works, but I am submitting this patch as a demonstration of how to make the error message seen in Issue #135 go away.

@b49020
Copy link
Contributor

b49020 commented May 29, 2024

@msgilligan Since it's a buildroot toolchain compiled from source in case of native aarch64 builds. I would like to see the linker path provided. Can you try following diff instead?

diff --git a/examples/acipher-rs/ta/Makefile b/examples/acipher-rs/ta/Makefile
index ad35909..498b22e 100644
--- a/examples/acipher-rs/ta/Makefile
+++ b/examples/acipher-rs/ta/Makefile
@@ -20,7 +20,7 @@ UUID ?= $(shell cat "../uuid.txt")
 TARGET ?= aarch64-unknown-linux-gnu
 CROSS_COMPILE ?= aarch64-linux-gnu-
 OBJCOPY := $(CROSS_COMPILE)objcopy
-LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)ld.bfd\"
+LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)ld\"
 
 TA_SIGN_KEY ?= $(TA_DEV_KIT_DIR)/keys/default_ta.pem
 SIGN := $(TA_DEV_KIT_DIR)/scripts/sign_encrypt.py
@@ -29,6 +29,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 all: ta strip sign
 
 ta:
+       @echo ${LINKER_CFG}
        @cargo build --target $(TARGET) --release --config $(LINKER_CFG)
 
 strip:

@msgilligan msgilligan force-pushed the msgilligan/aarch64-acipher-rs-hack branch from 732244f to 10d35e6 Compare May 29, 2024 18:11
@msgilligan
Copy link
Contributor Author

Since it's a buildroot toolchain compiled from source in case of native aarch64 builds.

After seeing the following line in setup.sh in this repository, I have been experimenting with using the standard apt toolchain on an aarch64 host:

apt update && apt -y install gcc-aarch64-linux-gnu gcc-arm-linux-gnueabihf

When I tried to apt install gcc-aarch64-linux-gnu I got the following message:

Note, selecting 'gcc' instead of 'gcc-aarch64-linux-gnu'
gcc is already the newest version (4:12.2.0-3).

So this lead me to create PR #137.

Can you try following diff instead?

It's force-pushed and I will try it out in my aarch64 Debian VM.

Please note the two commented-out lines in examples/acipher-rs/ta/build.rs. They set the following two linker options, which I suspect are necessary for proper TA operation (but have not tested yet):

--sort-section=alignment
--dynamic-list=dyn_list

This PR is meant to document my work-in-progress and to stimulate discussion, it is a "very drafty" DRAFT.

Note that I am new to OP-TEE, relatively new to Rust, have not used Rust in embedded environments before and am not knowledgeable about these linker options, so I'm experimenting and learning as I go along...

@msgilligan
Copy link
Contributor Author

msgilligan commented May 29, 2024

Can you try following diff instead?

It's force-pushed and I will try it out in my aarch64 Debian VM.

If I use this PR after the force-push of your diff, I get the following error message:

ld: cannot find -lgcc_s: No such file or directory

This is the same as with ld.bfd.

If I remove the --config $(LINKER_CFG) from the end of the @cargo line, the build successfully completes. So it seems the --config $(LINKER_CFG) must be doing more than just switching the linker command.

Is there a way to find out what else it is doing?

@b49020
Copy link
Contributor

b49020 commented May 30, 2024

Can you share the output of following echo command?

+       @echo ${LINKER_CFG}

@b49020
Copy link
Contributor

b49020 commented May 30, 2024

If I remove the --config $(LINKER_CFG) from the end of the @cargo line, the build successfully completes. So it seems the --config $(LINKER_CFG) must be doing more than just switching the linker command.

Is there a way to find out what else it is doing?

It is there to setup linker for the aarch64 target when Rust examples are being cross-compiled. However, here you are trying a native aarch64 Rust examples build which isn't tested before. Let me see if I can test it on a aarch64 machine too.

@msgilligan
Copy link
Contributor Author

msgilligan commented May 30, 2024

Can you share the output of following echo command?

+       @echo ${LINKER_CFG}
target.aarch64-unknown-linux-gnu.linker="ld"

@msgilligan msgilligan force-pushed the msgilligan/aarch64-acipher-rs-hack branch from 10d35e6 to 13935f6 Compare May 30, 2024 23:37
@msgilligan
Copy link
Contributor Author

@b49020 See #135 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants