Git Product home page Git Product logo

mod-elf-symbol's People

Contributors

j-h-k avatar jaekim95 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

mod-elf-symbol's Issues

Changing ET_DYN objects?

In src/mod-elf-symbol.c:294 there is a switch:

  switch(ehdr->e_type) {
  case ET_EXEC:
     printf("WARNING: The ELf type is that of an executable. (%s)\n", objFileName);
    break;
  case ET_REL:
    printf("SUCCESS: The ELF type is that of an relocatable. (%s)\n", objFileName);
    break;


Does the ET_DYN case require a different approach? Or is it simply not possible to do it?

Does not work on Arm (32bit)

Hi,
Trying to run this on an Arm platform and it's not working. When I run it I get the following:

./mod-elf-symbol -o foo.o -c foo --completestr=asdf
+++++++++++++++++++++++++++++++++ Started replace-symbols-name Program

The object files to modify are:
(0) foo.o

Complete Symbols planned on changing:
(0) foo --> asdf

SUCCESS: The ELF type is that of an relocatable. (foo.o)
mod-elf-symbol: src/mod-elf-symbol.c:736: main: Assertion `findSymtabAndStrtabAndShdr(objList[i], ehdr, &shdr, &symtab, &strtab) != -1' failed.
Aborted

Issue changing symbol for RISC-V 64-bit

HI,
We're doing some cross-compiling to RISC-V and trying to use Mod-ELF-Symbol to change some of the symbols in the resulting ELF file. Unfortunately it is crashing at:

mod-elf-symbol: src/mod-elf-symbol.c:546: extendAndFixAfterStrtab: Assertion `end_of_sections <= ehdr->e_shoff' failed.

I compiled with debug = 1 and also added one more printf to display the header shoff, ran it, and got:

./mod-elf-symbol -o /tmp/foo.o -c dsa_sub --completestr=asdfasdf

+++++++++++++++++++++++++++++++++ Started replace-symbols-name Program

The object files to modify are:
(0)	/tmp/foo.o

Complete Symbols planned on changing:
(0)	dsa_sub --> asdfasdf

SUCCESS: The ELF type is that of an relocatable. (foo.o)
symtab: size=3384 offset=0x17a4
strtab: size=4945 offset=0x3c0
0x40cd90 0x40cd10 Found Symbol table and String Table
symtab: size=3384 offset=0x17a4
strtab: size=4945 offset=0x3c0
In file foo.o symbols checked:
	Complete Symbols
		symbol: dsa_sub  |  sym->st_value: 0x14
ADD_SPACE is: 40
e_shoff:0x80
bns:0x1711  eos:0x1711
bns:0x1711  eos:0x1711 ptr:0x40ccd0
bns:0x1711  eos:0x1751 ptr:0x40cd10
bns:0x1711  eos:0x17a4 ptr:0x40cd50
bns:0x1711  eos:0x24dc ptr:0x40cd90
bns:0x1711  eos:0x38a8 ptr:0x40cdd0
bns:0x1711  eos:0x38b9 ptr:0x40ce10
bns:0x1711  eos:0x38bd ptr:0x40ce50
bns:0x1711  eos:0x38ef ptr:0x40ce90
bns:0x1711  eos:0x3b87 ptr:0x40ced0
bns:0x1711  eos:0x3b98 ptr:0x40cf10
bns:0x1711  eos:0x43ef ptr:0x40cf50
bns:0x1711  eos:0x84e7 ptr:0x40cf90
bns:0x1711  eos:0x84ff ptr:0x40cfd0
bns:0x1711  eos:0x867f ptr:0x40d010
bns:0x1711  eos:0x867f
mod-elf-symbol: src/mod-elf-symbol.c:546: extendAndFixAfterStrtab: Assertion `end_of_sections <= ehdr->e_shoff' failed.

For kicks I ran it under GDB and after the assertion failure I printed out:

(gdb) p end_of_sections 
$2 = 34431
(gdb) p *ehdr
$3 = {e_ident = "\177ELF\002\001\001\377\000\000\000\000\000\000\000", 
  e_type = 1, e_machine = 192, e_version = 1, e_entry = 0, e_phoff = 0, 
  e_shoff = 128, e_flags = 0, e_ehsize = 64, e_phentsize = 0, e_phnum = 0, 
  e_shentsize = 64, e_shnum = 14, e_shstrndx = 2}

So, not sure why the end_of_section is at 34K whereas the offset is only 128? In case it makes a difference:

od -t x1 foo.o | head
0000000 7f 45 4c 46 02 01 01 ff 00 00 00 00 00 00 00 00
0000020 01 00 c0 00 01 00 00 00 00 00 00 00 00 00 00 00
0000040 00 00 00 00 00 00 00 00 40 00 00 00 00 00 00 00
0000060 00 00 00 00 40 00 00 00 00 00 40 00 0e 00 02 00
0000100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*
0000200 01 00 00 00 03 00 00 00 00 00 00 00 00 00 00 00
0000220 00 00 00 00 00 00 00 00 c0 03 00 00 00 00 00 00
0000240 51 13 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0000260 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

For what it's worth, the ELF header, when it is first read into the program in checkAndFindElfFile, looks like:

$6 = {e_ident = "\177ELF\002\001\001\377\000\000\000\000\000\000\000", 
  e_type = 1, e_machine = 192, e_version = 1, e_entry = 0, e_phoff = 0, 
  e_shoff = 64, e_flags = 0, e_ehsize = 64, e_phentsize = 0, e_phnum = 0, 
  e_shentsize = 64, e_shnum = 14, e_shstrndx = 2}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.