Update documentation with ARM64 blazesym build workaround

Co-authored-by: yunwei37 <34985212+yunwei37@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-08-23 15:18:41 +00:00
parent 492e0e6c01
commit 5dc0c240d3
2 changed files with 49 additions and 28 deletions

View File

@@ -13,50 +13,65 @@ collect2: error: ld returned 1 exit status
This error occurs because the linker script used for generating test files is too aggressive in discarding sections, including the `.got.plt` section which is essential on ARM64 platforms. This error occurs because the linker script used for generating test files is too aggressive in discarding sections, including the `.got.plt` section which is essential on ARM64 platforms.
## Workarounds ## Solution
### Option 1: Skip Test File Generation (Recommended) **The tutorial repository already includes a workaround for this issue.** The examples that use blazesym (like `src/12-profile` and `src/16-memleak`) are configured to use the `dont-generate-test-files` feature flag when building blazesym.
The easiest workaround is to build blazesym with the `dont-generate-test-files` feature flag: You can see this in their Makefiles:
```makefile
$(LIBBLAZESYM_SRC)/target/release/libblazesym.a::
$(Q)cd $(LIBBLAZESYM_SRC) && $(CARGO) build --features=cheader,dont-generate-test-files --release
```
## If You Encounter This Issue
### For Tutorial Examples
Simply use the provided Makefiles:
```bash
cd src/12-profile # or src/16-memleak
make
```
### For Manual Blazesym Building
If you need to build blazesym manually, use the `dont-generate-test-files` feature:
```bash ```bash
cd src/third_party/blazesym cd src/third_party/blazesym
cargo build --features=cheader,dont-generate-test-files cargo build --features=cheader,dont-generate-test-files
``` ```
This flag skips the generation of test files that cause the linker issue. ### Alternative Workarounds
### Option 2: Install LLVM Tools 1. **Skip C Header Generation** (if you don't need C headers):
```bash
cd src/third_party/blazesym
cargo build
```
If you want to build with test files, ensure you have `llvm-gsymutil` installed: 2. **Install LLVM Tools** (if you want full test support):
```bash
# On Ubuntu/Debian:
sudo apt install llvm
```bash # Then build normally:
# On Ubuntu/Debian: cargo build --features=cheader
sudo apt install llvm ```
# On other systems, install LLVM development tools ## Technical Details
```
### Option 3: Use Fixed Linker Script The issue is caused by the linker script in `data/test-gsym.ld` being too aggressive in discarding sections. On ARM64 platforms, the `.got.plt` section is essential and cannot be discarded.
The linker script has been improved to be less aggressive about discarding sections. The fixed script avoids discarding essential sections like `.got.plt` that are needed on ARM64. The `dont-generate-test-files` feature flag bypasses the generation of test files that require this problematic linker script, allowing blazesym to build successfully while maintaining all core functionality.
## For Developers ## Impact
If you're working on examples that don't require blazesym's C header generation, you can simply build without the `cheader` feature: - **Core blazesym functionality**: ✅ Not affected
- **C header generation**: ✅ Works with the workaround
```bash - **Test file generation**: ⚠️ Skipped on problematic platforms
cd src/third_party/blazesym - **Symbol resolution**: ✅ Works normally
cargo build
```
## Additional Notes
- This issue is specific to ARM64 platforms and certain linker versions
- The workaround does not affect the core functionality of blazesym
- Test file generation is only needed for blazesym's internal testing, not for normal usage
## References ## References
- [Issue #148](https://github.com/eunomia-bpf/bpf-developer-tutorial/issues/148) - [Issue #148](https://github.com/eunomia-bpf/bpf-developer-tutorial/issues/148)
- [Blazesym Repository](https://github.com/libbpf/blazesym) - [Blazesym Repository](https://github.com/libbpf/blazesym)
- [ARM64 GOT/PLT Documentation](https://developer.arm.com/documentation/dui0803/j/ELF-features/Global-Offset-Table--GOT-)

View File

@@ -168,6 +168,12 @@ cd src/24-hide
make make
``` ```
## Known Issues
### ARM64 Build Issue with Blazesym
If you encounter build errors on ARM64 (aarch64) platforms related to blazesym, see [BLAZESYM_BUILD_WORKAROUND.md](BLAZESYM_BUILD_WORKAROUND.md) for solutions. The tutorial examples are already configured with appropriate workarounds.
## LICENSE ## LICENSE
MIT MIT