Editing files using elftoolchain - elf

I have managed to use elftoolchain to read ELF files, but I am having trouble editing ELF files.
I tried opening the ELF file using:
Elf *elf = elf_begin( ELF_C_RDWR, NULL);
I then just do nothing to the ELF object and then to write it back out I call:
elf_update(elf, ELF_C_WRITE);
I end up with a corrupted ELF file.
Note: I am using elftoolchain 0.6.1 as the install process for version 0.7.1 seems to overwrite the system ld.
Bonus: does anyone know how to write the elf file out to a different file descriptor from the one from which it was read in?

As long as you can use C++, just use this library instead: https://github.com/serge1/ELFIO

Related

With CMake, how to install CSV data file where library can find it?

I am working on a C library. It contains a data file, as a CSV file.
The library opens and read this file as needed.
But how do I install this file, and open it (in C) in such a way that it works in both testing and after it is installed?
Right now I copy the file to the build directory so it can be found during testing. But this won't work for an installed library.
# Copy the data file with the NOAA abbreviations.
configure_file(src/noaa_grib2_params.csv ${CMAKE_CURRENT_BINARY_DIR}/noaa_grib2_params.csv COPYONLY)
Even if I install the data file with the library, how can the library open it? Does the library have to know the install path so it can find the data file?

How to force CMake to relink project on resources change?

I have a very simple C++ executable and a few .txt resource files. At build time I embedd the .txt files into the C++ binary via linker and then I load them at runtime (based on this answer). That works great.
My problem is relinking. Whenewer I change the .cpp source of my executable and run make, the project rebuilds itself. However, if I change a .txt file and run make, the binary doesn't relink. How can I force CMake to watch changes to my resource files (.txt) so that when those change the executable gets relinked to contain the newest .txt resource files?
You can set a source property called OBJECT_DEPENDS containing the path to your .txt file. The file to set this property for should be any source that is included in your target.

Not able to create .so file in httpd-2.4.18

While I am installing httpd-2.4.18 on non stop hp, I am not able to create .so file in modules. It creates only .a file. But .so file is required in httpd.conf. How to create .so file ?
Make sure that you are using the SHARED pragma (assuming you are coding in C or C++) to make a DLL. I think that corresponds to your ".so" file.

Linking multiple static .lib files into one monolithic .lib file using VS2008 SP1 without extracting .lib files first

A basic question I have during my other question is this: Without first extracting the .lib files using the LIB.EXE command, how to I combine all .obj archive members together to form one larger monolithic .lib file? If I use the LIB.EXE or LINK.EXE utilities, some .obj files are omitted, presumably because there are no symbols defined in the omitted .obj files that are required by any other .obj file.
Without downloading and installing additional non-Microsoft software, and without first extracting all .obj files first, how do I combine them together?
You can't.
Think of a static-link .lib file as just a zipfile or tarfile containing some object files.
So you will have to find out what the contents are using lib /list, then extract each object out (one by one, that's the tedious part) using lib /extract, and once you've got everything ready, you build your new .lib.
If you're handy with a scripting language (Perl, Python, ...) it wouldn't be too hard to automate this chore. You could do it with batch commands (look for "for /F"; you'll need it) if you prefer.

Visual Basic Edit Tar Archive

Is it possible for vb to extract files from tar(and put them back)? I found this but it says that
Dim tar As New ChilkatTar <<<< ChilkatTar does not exist
I am trying to edit one xml file(which is not compressed) but if i do that with notepad, the tar becomes corrupt
ChilkatTar is a commercial component that you'd need to purchase, you can find it here:
7-zip supports unpacking and packing TAR files and is free so you could probably execute the command line version of it from your app to do the packing/unpacking.
It is also open-source, so you might even be able to copy the source into a library to use from your own application if you prefer, assuming that its license is compatible with your needs.