Linux文件已剥离,但仍包含不应存在的信息。

huangapple go评论64阅读模式
英文:

Linux file stripped, but still holds information it shouldn't

问题

I have a program which I stripped of all symbols, and confirmed as follows:

file /usr/local/mypapp
/usr/local/myapp: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=0f9f3c44a5bbbaefb0a64306e981323f5655e873, for GNU/Linux 3.2.0, stripped

My program contains a runtime error (Qt signal name is wrong), and at runtime the following error is written to the system log:

QObject::connect: No such signal RunProcessAsync::sig_write(ELevelWarning, Types::ESources, quint64, QString) in /mnt/myserver/data/development/myapp/src/external-sharedfiles/systemcommands/testfile.cpp:60

So it would appear the full name of the source file, the function call, and the class name are all still in the executable! How / why? The file is supposed to be stripped?

英文:

I have a program which I stripped of all symbols, and confirmed as follows:

file /usr/local/mypapp
/usr/local/myapp: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=0f9f3c44a5bbbaefb0a64306e981323f5655e873, for GNU/Linux 3.2.0, stripped

My program contains a runtime error (Qt signal name is wrong), and at runtime the following error is written to the system log:

QObject::connect: No such signal RunProcessAsync::sig_write(ELevelWarning, Types::ESources, quint64, QString) in /mnt/myserver/data/development/myapp/src/external-sharedfiles/systemcommands/testfile.cpp:60

So it would appear the full name of the source file, the function call, and the class name are all still in the executable! How / why? The file is supposed to be stripped?

答案1

得分: 2

正如Alan在上面所说,strip不会改变调试消息。strip的作用是从二进制文件中删除调试符号 - 这些是调试器(如gdb)使用的数据,存储在二进制文件的特殊部分。另一方面,调试消息是诸如qDebug()之类的内容,其中一些是由Qt的connect()函数自动生成的。使用编译标志QT_NO_DEBUG_OUTPUT将禁用这些消息。

你还应该考虑使用连接的较新语法,该语法使用模板在编译时验证连接语句,这将更容易防止像消息中标记的这样的错误。

英文:

As Alan said above, strip doesn't change debug messages. What strip does is remove debugging symbols from the binary - these are data used by debuggers such as gdb and are stored in special sections of a binary. Debug messages on the other hand are things like qDebug() and some of these are generated automatically for you by Qt's connect() function. Using the build flag QT_NO_DEBUG_OUTPUT will disable these messages.

You should also consider using the newer syntax for connect that uses templates to validate your connect statements at compile time. This will make it easier to prevent errors such as the one that message is flagging.

huangapple
  • 本文由 发表于 2023年5月7日 00:25:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/76189966.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定