NASM - The Netwide Assembler
NASM Forum => Programming with NASM => Topic started by: clockworkd on March 04, 2020, 08:23:48 AM
-
Hullo there,
I've just been adding DWARF debugging information to the output of my BASIC compiler (x86-64, Linux). Everything was going well, however I've hit a problem. Local labels (dotted) and constants defined with equ make their way into the final executable. So when I ask the GNU debugger for a backtrace, I get lots of irrelevant information. (For example, each function has a little "helper" function that zeroes the stack, and some equs that record call frame information). The backtrace is thus quite confusing to read.
Is there anyway to make it so these symbols don't end up in the final binary - just the function names themselves?
Thanks.
-
I am fairly certain that there is nothing Nasm itself can do for you. Adding the "-s" switch to ld will strip all debugging information, which is not what you want! It is remotely possible that the "strip" utility can strip some symbols but not others. I kinda doubt it. Think about how any utility would know that you consider certain information "irrelevant". If you left it out, your program wouldn't work as intended... As such, I think it's going to be up to you to skip over the "irrelevant" parts. I could be wrong...
Best,
Frank
-
Thank-you Frank for your quick answer. After I posted this topic I saw on stackoverflow that someone mentioned that the strip command supports wildcards and so might be able to strip everything containing a dot. I'll have a look into that.
Would the nasm developers accept a patch to add this partial stripping functionality as a command line switch? I think it would make nasm much more useful as a compiler backend and bring it more into line with fasm.
-
I am not currently involved in Nasm development. You could ask.
If you replace the "equ"s with "%define"s, this might keep that info out of your executable.
Best,
Frank
-
Hi,
When I tried using %defines nasm made several complaints, something about expressions not being constant, or simple or relocatable. :-\
Well, I have asked, now! :)
-
I've written a patch now so will hopefully email it off tomorrow. Who is the best person to email it to?
To clarify, it's not a patch to invoke "strip' or anything heavy-handed like that, I've just added a command line switch to optionally stop nasm spewing out all the unwanted labels in the first place.
-
https://sourceforge.net/projects/nasm/lists/nasm-devel
Best,
Frank
-
Hullo again Frank.
Sorry for being dumb - after I read your message I saw that there was a file called SubmittingPatches which had this info.
I've submitted my patch now. It'd be really cool if it was merged because I've never contributed to (someone else's) free software project before.