On Sonntag, 18. Juli 2021 13:06:18 CEST Troed Sångberg wrote:
(I'm also not sure I understand what you mean, the symbols table has the
addresses - so unless $1000 was a valid symbol it would not be replaced)
Yes, but that was just an example. Replace $10000 by $70000 and you may end up
with a value that might as well be a valid program address, but actually
wasn't used that way.
In an object file, you have relocation entries. That means there is an info
about the 2nd instruction that the symbol "mylabel" was referenced there. But
such relocation information is missing in linked programs. So you can try to
do some heuristic about values being inside the programs text/data/bss
segments, but then you might end up with printing some unrelated symbol name
for the first instruction in my example, and that might be even more
confusing.