1

My goal is to make symbols visible for dlsym for futher use.

Currently all symbols are in the .symtab

I tried using LIEF to export them, but always got Exec format error after modification

my elf file: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, not stripped

As far as I know symbols have to be located in dynamic table to be accessible using dlsym but haven't found anything which could do that.

Honza Bednář
  • 396
  • 4
  • 14

2 Answers2

2

As far as I know symbols have to be located in dynamic table to be accessible using dlsym

Correct.

but haven't found anything which could do that.

Rebuilding the dynamic symbol table such that it includes new symbols is very involved (you need to rebuild the .hash or .gnu.hash as well), so I am not surprised you can't find any tools which reliably do that.

You probably should look for another method of achieving whatever it is you are trying to achieve (see also XY problem).

Employed Russian
  • 199,314
  • 34
  • 295
  • 362
1

You can supply the linker with the --export-dynamic flag to achieve exactly what you are looking for.

Abhiroop Sarkar
  • 2,251
  • 1
  • 26
  • 45