1

I'm trying to change the RUNPATH of a shared object but I get an error that it cannot be longer than 6 characters. What is the reason for this? This is chrpath version 0.16 on Raspbian.

$ chrpath -r ../../.. lib/vlc/plugins/access_output/libaccess_output_srt_plugin.so
lib/vlc/plugins/access_output/libaccess_output_srt_plugin.so: RUNPATH=../lib
new rpath '../../..' too large; maximum length 6

I was able to set a longer path using patchelf.

Elliott B
  • 565

2 Answers2

2

chrpath can’t add an RPATH tag if one isn’t present, and it can’t extend one; as a result, the new path must be of equal length to or shorter than the existing path. Your library started out with a RUNPATH set to ../lib, so chrpath can only replace that with a path of six characters at most.

patchelf doesn’t have that limitation.

Stephen Kitt
  • 434,908
  • Oh! Weird. I guess that answers the question, but why?? This limitation doesn't make sense. – Elliott B Jan 13 '21 at 17:36
  • chrpath doesn't fully re-write the ELF file, giving it the ability to change offsets and allocations. Instead it uses the existing space that was allocated for the prior value. It similar to changing string contents in a binary manually with a hex editor - everything must fit the existing space.

    patchelf is implemented differently.

    – R Perrin Jan 13 '21 at 23:07
1

The new set of paths for rpath or runpath can't be larger then the one originally stored (Code Yarns site).

Your previous rpath was exactly 6 chars, it's ../lib in your example. You can't extend it.

As @R Perrin stated, chrpath doesn't rewrite the whole ELF file using existing space that is itself limited to what was set originally.

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255