pkgsrc-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: pkg/59096: qt6 apps with qt6-qtbase don't work on NetBSD/earmv7hf 10.1
The following reply was made to PR pkg/59096; it has been noted by GNATS.
From: Izumi Tsutsui <tsutsui%ceres.dti.ne.jp@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: tsutsui%ceres.dti.ne.jp@localhost
Subject: Re: pkg/59096: qt6 apps with qt6-qtbase don't work on NetBSD/earmv7hf
10.1
Date: Mon, 8 Sep 2025 04:28:56 +0900
> >Synopsis: qt6 apps with qt6-qtbase don't work on NetBSD/earmv7hf 10.1
This is caused by incorrect alignment rounding in ELF note parser.
src/corelib/plugin/qelfparser_p.cpp:scanProgramHeadersForNotes()
has the following calculations to search and parse note sections:
https://github.com/qt/qtbase/blob/6.8.3/src/corelib/plugin/qelfparser_p.cpp#L619-L630
```
// overflow check: calculate where the next note will be, if it exists
T::Off next_offset = offset;
next_offset += sizeof(T::Nhdr); // can't overflow (we checked above)
next_offset += NoteAlignment - 3; // offset is aligned, this can't overflow
if (qAddOverflow<T::Off>(next_offset, n_namesz, &next_offset))
break;
next_offset &= -NoteAlignment;
next_offset += NoteAlignment - 3; // offset is aligned, this can't overflow
if (qAddOverflow<T::Off>(next_offset, n_descsz, &next_offset))
break;
next_offset &= -NoteAlignment;
```
I'm not sure where 'NoteAlignment - 3' comes from (3 should be 1?),
but NetBSD/earmv7hf binaries has .note.netbsd.march section where
n_descsz==9 and in that case the above rounding calculation add
only 8 bytes to `next_offset` rather than 12 bytes, so it fails
to find the next .note.qt.metadata section.
It would be simpler to use explicit roundup calculations
(pulled from local patches/patch-src_corelib_plugin_qelfparser__p.cpp):
```
$NetBSD$
- fix wrong alignment calculations that could fail on NetBSD/earmv7hf
where n_descsz==9 in .note.netbsd.march section just before
.not.qt.metadata
--- src/corelib/plugin/qelfparser_p.cpp.orig 2024-10-01 10:46:30.000000000 +0000
+++ src/corelib/plugin/qelfparser_p.cpp
@@ -619,15 +619,15 @@ static QLibraryScanResult scanProgramHea
// overflow check: calculate where the next note will be, if it exists
T::Off next_offset = offset;
next_offset += sizeof(T::Nhdr); // can't overflow (we checked above)
- next_offset += NoteAlignment - 3; // offset is aligned, this can't overflow
- if (qAddOverflow<T::Off>(next_offset, n_namesz, &next_offset))
+ // roundup n_namesz and n_descsz to NoteAlignment
+ const T::Off AlignOffset = T::Off(NoteAlignment - 1);
+ const T::Off AlignMask = ~AlignOffset;
+ const T::Off round_namesz = (T::Off(n_namesz) + AlignOffset) & AlignMask;
+ const T::Off round_descsz = (T::Off(n_descsz) + AlignOffset) & AlignMask;
+ if (qAddOverflow<T::Off>(next_offset, round_namesz, &next_offset))
break;
- next_offset &= -NoteAlignment;
-
- next_offset += NoteAlignment - 3; // offset is aligned, this can't overflow
- if (qAddOverflow<T::Off>(next_offset, n_descsz, &next_offset))
+ if (qAddOverflow<T::Off>(next_offset, round_descsz, &next_offset))
break;
- next_offset &= -NoteAlignment;
if (next_offset > end_offset)
break;
```
---
Izumi Tsutsui
Home |
Main Index |
Thread Index |
Old Index