Need help stripping a section from a .so - llvm

I need some help with llvm-strip / llvm-objcopy.
I've built a shared object, using -fembed-bitcode. When looking into it, it has a section .llvmbc which I would like to strip (I know, I could just remove the flag, but this is an example for learning :))
Using llvm-strip, I'm able to use --remove-section to remove the .llvmbc section, but that doesn't seems to remove the bitcode from the .so, as the size doesn't change. What I would like, is for the bitcode to be removed, similar to how debug symbols can be stripped out of the .so, but I couldn't figure out a way to do this. I also tried with llvm-objcopy but I get the same behavior.
Is there any option that I'm missing in llvm-strip or llvm-objcopy ? Or do I need to use another tool to do this ?
Thanks !

Related

Is it possible to change constexpr-ops-limit inside the source file?

I want to change constexpr-ops-limit to a bigger number. I know that it is possible with -fconstexpr-ops-limit= as a command line argument, but I have no possibility to change arguments because I submit my code to a system that runs it automatically. I wonder if there are any pragmas in GCC or VC++ that will match my needs.
Is there any way to do it? Thank you in advance.

Getting specfic files in C++ code from *nix system

I want to get all the files of type A*.txt present in current directory via C++ code. My OS is *Nix system. Also, I want to get the names of such files.
Please suggest how can this be done.
I tried using system command but system doesn't return anything apart a integer which says if command was executed properly or not.
Thanks
There are basically three ways you can go about this.
One is to use basically what you tried before, but using the popen function, which allows you to read the output of the command(s) you run.
The second solution is to use e.g. opendir and readdir or scandir to manually filter and find the files you look for.
The third and easiest way is to use the glob function.
There is actually a fourth way as well, one which is platform independent and more C++-ish than the above methods: Using the Boost filesystem library.

How do you remove directory qualifiers to simplify pathname using the Win32 API?

If you have a path like "C:\foo\.\bar\.." is there an easy way using the Win32 API to remove the directory qualifiers in order to simplify it to "C:\foo" ?
Update: It seems to be a more complicated issue. On this simple example of "C:\foo\.\bar\..", it works with both PathCanonicalize() and GetFullPathName() to get "C:\foo" as a result.
However, the path I'm passing has a symbolic link. So let's say I'm passing in "C:\NaNa\Boo\Bin\.." and "C:\NaNa" is a link to "D:\Apple". Then I get "C:\NaNa\Boo\Bin\.." back ratener than "C:\NaNa\Boo"
I would assume the functions work with just the strings but there seems to be a difference when using the symbolic link :-(
Update #2: It appears I had a line break character (0x0d) in the string that was passed in and this kept the function from working properly!
Take a look at shlwapi's PathCanonicalize()

DirectX HLSL Include Directive Doesn't Work

The document:
http://msdn.microsoft.com/en-us/library/dd607349(v=vs.85).aspx
states that #include "foobar.fx" will look for that file in the same directory as the current effect file.
It doesn't work, but using an absolute path does, which is of course useless.
Google doesn't come up with anything. Anything I'm missing here?
There is a default include handler for the Direct3D 11 On-the-fly shader compiler.
It's a macro: (c++)
D3D_COMPILE_STANDARD_FILE_INCLUDE
Here's a link to the D3DCompile function.
http://msdn.microsoft.com/en-us/library/windows/desktop/dd607324(v=vs.85).aspx
The macro is mentioned in the explanation of the include variable.
It took me a while to find with google oddly enough, but I passed here on the way.
I thought I'd post it in case anyone else ends up here.
That automatic handling only works for the offline shader compiler tool, as mentioned in the link you provided. If you're compiling using one of the APIs, you'll need to specify an include handler for the compiler to use whenever it encounters an include directive: ID3DInclude

Using windows CopyFile function to copy all files with certain name format

Hello! I am updating some C code that copys files with a certain name. basically, I have a directory with a bunch of files named like so:
AAAAA.1.XYZ
AAAAA.2.ZYX
AAAAA.3.YZX
BBBBB.1.XYZ
BBBBB.2.ZYX
Now, In the old code, they just used a call to ShellExecute and used xcopy.exe. to get all the files starting with AAAAA, they just gave xcopy the name of the file as AAAAA.* and it knew to copy all of the files starting with AAAAA. now, im trying to get it to copy with out having to use the command line, and I am running into trouble. I was hoping CopyFile would be smart enough to handle AAAAA.* as the file to be copied, but it doesnt at all do what xcopy did. So, any Ideas on how to do this without the external call to xcopy.exe?
Check this out as a starting point
http://msdn.microsoft.com/en-us/library/aa364418(VS.85).aspx
or even better this full example
http://msdn.microsoft.com/en-us/library/aa365200(v=VS.85).aspx
You could also use SHFileOperation or IFileOperation (the latter being only available from Vista upwards but is now the recommended way according to MSDN). SHFileOperation supports wildcards and displays a progress by default, but there's also a flag for silent operation.
Check out the following MSDN links for more info:
http://msdn.microsoft.com/en-us/library/bb762164(v=VS.85).aspx
http://msdn.microsoft.com/en-us/library/bb775771(v=VS.85).aspx
You would basically have to write code to reproduce the functionality in xcopy. To do so, you must build a list of files by accessing the path and recursing through it. Test each found entry with your pattern and keep only those that match. Then iterate over that list with CopyFile.
See the following set of functions that can help you build the file list:
http://en.wikipedia.org/wiki/Dirent.h
It might just be easier to keep using xcopy unless you have a specific reason not to.
There are lots of ways to do it. I'd probably use a loop of FindFirstFile() / FindNextFile().
However, is there any reason you can't still use xcopy? You can launch it with CreateProcess(). It isn't pretty, but it works.