llvm / llvm/llvm-project

`obj2yaml` does not seem to preserve dependency information for ELF shared libraries

Open
#161,513 3 comments 0 reactions 0 assignees View on GitHub
objectyaml question
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

When converting an ELF shared library (`.so`) to YAML using `obj2yaml` and then back to a `.so` using `yaml2obj`, the `NEEDED` entries do not appear to be preserved as expected. Instead of the shared library names, the output shows numeric values.

I am not sure if this is the intended behavior or a missing feature/bug.

**Steps:**

```bash
# Original .so has dependencies:
0x0000000000000001 (NEEDED) Shared library: [libA.so]
0x0000000000000001 (NEEDED) Shared library: [libB.so]
0x0000000000000001 (NEEDED) Shared library: [libD.so]
0x0000000000000001 (NEEDED) Shared library: [libZ.so]

# Convert original .so → yaml → new .so
obj2yaml original.so > lib.yaml
yaml2obj lib.yaml > new.so

# New .so shows:
# readelf -d libC.so | grep NEEDED
0x0000000000000001 (NEEDED) 0x6e
0x0000000000000001 (NEEDED) 0x76
0x0000000000000001 (NEEDED) 0x7e
0x0000000000000001 (NEEDED) 0x86
```

**Environment:**

* Host: macOS (Apple M1)
* Running inside Docker:

```bash
docker run --platform=linux/amd64 -it --rm -v $(pwd):/workspace ubuntu:22.04
```

* LLVM version: `22.0.0git` (built inside Docker)

Library Build : https://gist.github.com/SahilPatidar/00a46afc5e3168b992c6e51974c9853d

Is this the expected behavior for `obj2yaml`/`yaml2obj` with ELF?

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the obj2yaml original.so to lib.yaml and yaml2obj lib.yaml to new.so workflow, then compare the NEEDED entries with readelf. Trace how obj2yaml and yaml2obj handle ELF shared-library dependencies; done means the rebuilt .so preserves the original library names instead of numeric values.

Written by the indexing model from the issue text.

Assessment

Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.