45 #if defined (Q_OF_ELF) && defined(Q_CC_GNU) 54 const char *QElfParser::parseSectionHeader(
const char *
data, ElfSectionHeader *sh)
56 sh->name = read<qelfword_t>(
data);
57 data +=
sizeof(qelfword_t);
58 sh->type = read<qelfword_t>(
data);
59 data +=
sizeof(qelfword_t)
62 sh->offset = read<qelfoff_t>(
data);
63 data +=
sizeof(qelfoff_t);
64 sh->size = read<qelfoff_t>(
data);
65 data +=
sizeof(qelfoff_t);
71 #if defined(QELFPARSER_DEBUG) 72 qDebug() <<
"QElfParser::parse " << library;
80 const char *data = dataStart;
81 if (
qstrncmp(data,
"\177ELF", 4) != 0) {
87 if (data[4] != 1 && data[4] != 2) {
92 m_bits = (data[4] << 5);
97 if ((
sizeof(
void*) == 4 && m_bits != 32) || (
sizeof(
void*) == 8 && m_bits != 64)) {
108 m_endian = (data[5] == 1 ? ElfLittleEndian : ElfBigEndian);
117 qelfoff_t e_shoff = read<qelfoff_t> (
data);
118 data +=
sizeof(qelfoff_t)
119 +
sizeof(qelfword_t);
121 qelfhalf_t e_shsize = read<qelfhalf_t> (
data);
123 if (e_shsize > fdlen) {
129 data +=
sizeof(qelfhalf_t)
131 +
sizeof(qelfhalf_t);
133 qelfhalf_t e_shentsize = read<qelfhalf_t> (
data);
135 if (e_shentsize % 4){
140 data +=
sizeof(qelfhalf_t);
141 qelfhalf_t e_shnum = read<qelfhalf_t> (
data);
142 data +=
sizeof(qelfhalf_t);
143 qelfhalf_t e_shtrndx = read<qelfhalf_t> (
data);
144 data +=
sizeof(qelfhalf_t);
146 if ((
quint32)(e_shnum * e_shentsize) > fdlen) {
149 .
arg(
QLatin1String(
"announced %2 sections, each %3 bytes, exceed file size"))
150 .
arg(e_shnum).
arg(e_shentsize);
154 #if defined(QELFPARSER_DEBUG) 158 ElfSectionHeader strtab;
159 qulonglong soff = e_shoff + e_shentsize * (e_shtrndx);
161 if ((soff + e_shentsize) > fdlen || soff % 4 || soff == 0) {
169 parseSectionHeader(dataStart + soff, &strtab);
170 m_stringTableFileOffset = strtab.offset;
172 if ((
quint32)(m_stringTableFileOffset + e_shentsize) >= fdlen || m_stringTableFileOffset == 0) {
180 #if defined(QELFPARSER_DEBUG) 184 const char *s = dataStart + e_shoff;
185 for (
int i = 0; i < e_shnum; ++i) {
187 parseSectionHeader(s, &sh);
192 const char *shnam = dataStart + m_stringTableFileOffset + sh.name;
194 if (m_stringTableFileOffset + sh.name > fdlen) {
202 #if defined(QELFPARSER_DEBUG) 203 qDebug() <<
"++++" << i << shnam;
206 if (
qstrcmp(shnam,
".qtplugin") == 0 ||
qstrcmp(shnam,
".rodata") == 0) {
207 if (!(sh.type & 0x1)) {
208 if (shnam[1] ==
'r') {
214 #if defined(QELFPARSER_DEBUG) 215 qDebug()<<
"section is not program data. skipped.";
221 if (sh.offset == 0 || (sh.offset + sh.size) > fdlen) {
228 *sectionlen = sh.
size - 1;
239 #endif // defined(Q_OF_ELF) && defined(Q_CC_GNU) 240 #endif // QT_NO_LIBRARY static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
int qstrncmp(const char *str1, const char *str2, uint len)
#define QT_END_NAMESPACE
This macro expands to.
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
int qstrcmp(const char *str1, const char *str2)
A safe strcmp() function.
Q_CORE_EXPORT void qDebug(const char *,...)
#define QT_BEGIN_NAMESPACE
This macro expands to.
int size() const
Returns the number of characters in this string.
static const char * data(const QByteArray &arr)
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
static QByteArray number(int, int base=10)
Returns a byte array containing the string equivalent of the number n to base base (10 by default)...