retitle 629498 ld.bfd: "could not read symbols: Invalid operation" after
indirect reference is unhelpful
# cosmetic
severity 629498 minor
tags 629498 + upstream
quit
Philip Ashmore wrote:
> /usr/bin/ld: allocator_test_16-allocator-test.o: undefined reference to
> symbol 'v3c_native_endian_index'
> /usr/bin/ld: note: 'v3c_native_endian_index' is defined in DSO
> /v3c/dev/autobook/treedb/build/v3c/.libs/libtreedb-0.9-bare.so.902 so try
> adding it to the linker command line
> /v3c/dev/autobook/treedb/build/v3c/.libs/libtreedb-0.9-bare.so.902: could not
> read symbols: Invalid operation
The last error message is used by 'gld${EMULATION_NAME}_try_needed' to
indicate that 'bfd_link_add_symbols' failed.
More precisely: we have finished opening input files, so ld lists
DT_NEEDED entries of DSOs listed on the command line. For each
such entry, ld will discard it if it was not really needed (because
redundant or because none of its symbols are referenced and
--as-needed is in use); otherwise, it finds the library and includes
its symbol table in the linker hash table.
The unfortunate message comes because bfd_link_add_symbols has no
way to return a meaningful error so it just prints a message itself
and returns an error code. And the list of error codes is kind of
crazy:
System call error - i.e., see "errno"
Invalid bfd target - i.e., unrecognized target name, or:
trying to do something that doesn't
work for this target.
File in wrong format - i.e., malformed input, or:
operation doesn't make sense for
this kind of file
Archive object file in wrong format
- i.e., archive contains objects for
the wrong target
Invalid operation - operation doesn't make sense for
this situation or kind of file
Memory exhausted - why not System call error, errno == ENOMEM?
No symbols - symbol table is empty
Archive has no index; run ranlib to add one
No more archived files
Malformed archive
File format not recognized
- could not pick a target (e.g., bad magic
bytes)
File format is ambiguous
- matched more than one non-default target
while we were trying to autodetect
Section has no contents
- The output section does not have the
<<SEC_HAS_CONTENTS>> attribute, so nothing
can be written to it.
Nonrepresentable section on output
Symbol needs debug section which does not exist
Bad value
File truncated
File too big
Error reading %s: %s
#<Invalid error code>
So what actually happened here? "Invalid operation" is definitely
wrong. ld *could* read the symbols in libtreedb-0.9-bare --- it just
didn't want to use them. I guess a better error message would be
libtreedb-0.9-bare.so.902: could not get symbols: Refusing to traverse
DT_NEEDED link to resolve symbols
or something like that.
Will think more.
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]