# Type *.o files. How does one edit?



## sossego (Jun 26, 2013)

In the $PATH/ardour-$BETA/, there are the files prior to becoming executable. An error is called which cannot be accessed by the simple vi method.


----------



## ta0kira (Jun 26, 2013)

Those are object files, which are in a binary format. The proper way to change them is to edit the source code (C++, C, asm, etc.) and recompile. Or, if you know what you're doing already, try a hex editor.

Kevin Barry


----------



## jozze (Jun 26, 2013)

As @ta0kira suggested you have to use hexadecimal view. You can use vi (or vim) to do this, with [cmd=":"]%!xxd[/cmd], and then exit from it using the [cmd=":"]%!xxd -r[/cmd].


----------



## sossego (Jun 26, 2013)

Where do I go to learn about properly replacing the values within the executable?


----------



## jozze (Jun 26, 2013)

If your source code compiles, perhaps you can use the gdb(1)() to see which pointers are linked with which variables. To use it properly, compile your code with -g flag. gdb will work regardless of gcc vs. clang, and both support -g flag.

If you don't have the source available, and you need just to modify the binary, try  elf(3)(), elf(5)() and gelf(3)(). I'm guessing your binary is in ELF format (the first line in hexadecimal should state `ELF'). It doesn't say how to change that file, but maybe it will give you further clues.

I also searched on the internet a little: to modify executables in an IDE fashion + debugger functionality, you can try editors/hte which this website recommends. Also see this link on StackOverflow about patching an ELF file.


----------



## sossego (Jun 27, 2013)

Hmmm. I did not do debugging with this almost-build of Ardour. Yeah, it states ELF. <-- Just like that.


----------



## jozze (Jun 27, 2013)

I also remembered another program, which you can use to find information about binaries: objdump(1)(). It's a very good program which very thoroughly dissects the binary file, and with the -S flag also gives you quite a lot of information about the sources, which were used to construct the binary.


----------



## kpa (Jun 27, 2013)

Two other useful utilities, elfdump(1) and nm(1).

Undefined dynamic symbols in an executable or a library:

```
[CMD=firewall ~ %]nm --dynamic --undefined-only /usr/lib/libc.so[/CMD]
         w _Jv_RegisterClasses
         U __progname
         w __pthread_cxa_finalize
         U environ
```


----------



## expl (Jun 27, 2013)

sossego said:
			
		

> In the $PATH/ardour-$BETA/, there are the files prior to becoming executable. An error is called which cannot be accessed by the simple vi method.



Unless you have solid understanding of ELF format and assembler, I would not recommend trying to edit the object files. Unless you have plenty of time to learn reverse engineering, in that case I would recommend starting with some more simple examples and work your way up.

Is there no way for you to get hold of the source that spawned those object files?


----------



## sossego (Jun 27, 2013)

I have the $PORT/work directory still intact on the laptop. The `--system-generic` is a flag for apple i386 systems in the  wscript ./waf options. Patching to the source code was done with {apple $OPTION}{FreeBSD} in the patch files for $PORT. If need be, there is always the option of uploading the beta.bz2 to google code for others to download and view.


----------

