Skip site navigation (1)Skip section navigation (2)
To:        John F Carr <jfc@mit.edu>, Konstantin Belousov <kostikbel@gmail.com>, Baptiste Daroussin <bapt@FreeBSD.org>

| raw e-mail | index | archive | help
On Jul 21, 2024, at 21:08, Mark Millard <marklmi@yahoo.com> wrote:

> On Jul 21, 2024, at 20:58, Mark Millard <marklmi@yahoo.com> wrote:
>=20
>> I found a significant difference in my failing vs. working
>> armv7 contexts as installed: Presence vs. Lack of a .symtab
>> entry for the symbol _rtld_get_stack_prot in
>> /libexec/ld-elf.so.1 .
>>=20
>> gdb inspection of operation shows distinctions based on
>> the difference.
>>=20
>> This is related to the code:
>>=20
>> (gdb) list  140
>> 135 void
>> 136 _thr_stack_fix_protection(struct pthread *thrd)
>> 137 {
>> 138=20
>> 139 mprotect((char *)thrd->attr.stackaddr_attr +
>> 140    round_up(thrd->attr.guardsize_attr),
>> 141    round_up(thrd->attr.stacksize_attr),
>> 142    _rtld_get_stack_prot());
>> 143 }
>>=20
>>=20
>> Working context (Personal build):
>>=20
>> NOTE THE .symtab ENTRY BELOW. It allows the gdb run to work:
>>=20
>> # readelf -a /libexec/ld-elf.so.1 | grep -E "(^[^ =
0-9]|.*_rtld_get_stack_prot)" | less
>> ELF Header:
>> Elf file type is DYN (Shared object file)
>> Entry point 0x14548
>> There are 10 program headers, starting at offset 52
>> Program Headers:
>> There are 24 section headers, starting at offset 0x1f2b8:
>> Section Headers:
>> Key to Flags:
>> Dynamic section at offset 0x199f8 contains 15 entries:
>> Relocation section (.rel.dyn):
>> r_offset r_info   r_type              st_value st_name
>> Symbol table '.dynsym' contains 27 entries:
>>    5: 000000000001b9ac    16 FUNC    GLOBAL DEFAULT   11 =
_rtld_get_stack_prot@@FBSDprivate_1.0 (11)
>> Symbol table '.symtab' contains 911 entries:
>>  903: 000000000001b9ac    16 FUNC    GLOBAL DEFAULT   11 =
_rtld_get_stack_prot
>> Notes at offset 0x00000174 with length 0x00000018:
>> Histogram for bucket list length (total of 6 buckets):
>> Histogram for bucket list length (total of 27 buckets):
>> Version symbol section (.gnu.version):
>> Version definition section (.gnu.version_d):
>> Attribute Section: aeabi
>> File Attributes
>>=20
>>=20
>> Breakpoint 8.3, _thr_stack_fix_protection (thrd=3D0x2006f000) at =
/usr/main-src/lib/libthr/thread/thr_stack.c:139
>> 139 mprotect((char *)thrd->attr.stackaddr_attr +
>> (gdb) si
>> 141    round_up(thrd->attr.stacksize_attr),
>> (gdb)=20
>> 140    round_up(thrd->attr.guardsize_attr),
>> (gdb)=20
>> round_up (size=3D4096) at =
/usr/main-src/lib/libthr/thread/thr_stack.c:129
>> 129 if (size % _thr_page_size !=3D 0)
>> (gdb)=20
>> 0x201110b8 129 if (size % _thr_page_size !=3D 0)
>> 130 size =3D ((size / _thr_page_size) + 1) *
>> (gdb)=20
>> 0x201110c0 130 size =3D ((size / _thr_page_size) + 1) *
>> (gdb)=20
>> 0x201110c4 in round_up (size=3D4096) at =
/usr/main-src/lib/libthr/thread/thr_stack.c:130
>> 130 size =3D ((size / _thr_page_size) + 1) *
>> (gdb)=20
>> 0x201110c8 130 size =3D ((size / _thr_page_size) + 1) *
>> (gdb)=20
>> round_up (size=3D67108864) at =
/usr/main-src/lib/libthr/thread/thr_stack.c:129
>> 129 if (size % _thr_page_size !=3D 0)
>> (gdb)=20
>> 0x201110d0 in round_up (size=3D4096) at =
/usr/main-src/lib/libthr/thread/thr_stack.c:129
>> 129 if (size % _thr_page_size !=3D 0)
>> (gdb)=20
>> 0x201110d4 in round_up (size=3D67108864) at =
/usr/main-src/lib/libthr/thread/thr_stack.c:129
>> 129 if (size % _thr_page_size !=3D 0)
>> (gdb)=20
>> 0x201110d8 129 if (size % _thr_page_size !=3D 0)
>> (gdb)=20
>> 0x201110dc in round_up (size=3D4096) at =
/usr/main-src/lib/libthr/thread/thr_stack.c:129
>> 129 if (size % _thr_page_size !=3D 0)
>> (gdb)=20
>> 0x201110e0 129 if (size % _thr_page_size !=3D 0)
>> (gdb)=20
>> _thr_stack_fix_protection (thrd=3D0x2006f000) at =
/usr/main-src/lib/libthr/thread/thr_stack.c:139
>> 139 mprotect((char *)thrd->attr.stackaddr_attr +
>> (gdb)=20
>> 142    _rtld_get_stack_prot());
>> (gdb)=20
>> 0x20114880 in ?? () from /lib/libthr.so.3
>> (gdb)=20
>> 0x20114884 in ?? () from /lib/libthr.so.3
>> (gdb)=20
>> 0x20114888 in ?? () from /lib/libthr.so.3
>> (gdb)=20
>>=20
>> Breakpoint 9.1, _rtld_get_stack_prot () at =
/usr/main-src/libexec/rtld-elf/rtld.c:5884
>> 5884 return (stack_prot);
>> (gdb)=20
>> 0x2005b9b0 5884 return (stack_prot);
>> (gdb)=20
>> 0x2005b9b4 5884 return (stack_prot);
>>=20
>>=20
>>=20
>> Failing context (Official PkgBase build):
>>=20
>> NOTE THE *LACK OF* THE .symtab ENTRY ABOVE.
>=20
> Not "ABOVE": BELOW! Sorry.
>=20
>> _rtld_bind_start ends
>> up in use instead, which looks to lead to the gdb run not working.
>>=20
>> IN FACT, NOTE THE LACK OF ANY "Symbol table '.symtab' contains"
>> TEXT AT ALL!
>>=20
>> # readelf -a /libexec/ld-elf.so.1 | grep -E "(^[^ =
0-9]|.*_rtld_get_stack_prot)" | less
>> ELF Header:
>> Elf file type is DYN (Shared object file)
>> Entry point 0x147b0
>> There are 10 program headers, starting at offset 52
>> Program Headers:
>> There are 22 section headers, starting at offset 0x1a960:
>> Section Headers:
>> Key to Flags:
>> Dynamic section at offset 0x1a4cc contains 15 entries:
>> Relocation section (.rel.dyn):
>> r_offset r_info   r_type              st_value st_name
>> Symbol table '.dynsym' contains 27 entries:
>>    5: 000000000001bcd8    16 FUNC    GLOBAL DEFAULT   11 =
_rtld_get_stack_prot@@FBSDprivate_1.0 (11)
>> Notes at offset 0x00000174 with length 0x00000018:
>> Histogram for bucket list length (total of 6 buckets):
>> Histogram for bucket list length (total of 27 buckets):
>> Version symbol section (.gnu.version):
>> Version definition section (.gnu.version_d):
>> Attribute Section: aeabi
>> File Attributes
>>=20
>>=20
>> Breakpoint 2.3, _thr_stack_fix_protection (thrd=3D0x20070000) at =
/home/pkgbuild/worktrees/main/lib/libthr/thread/thr_stack.c:140
>> 140    round_up(thrd->attr.guardsize_attr),
>> (gdb) si
>> 139 mprotect((char *)thrd->attr.stackaddr_attr +
>> (gdb)=20
>> 141    round_up(thrd->attr.stacksize_attr),
>> (gdb)=20
>> round_up (size=3D4096) at =
/home/pkgbuild/worktrees/main/lib/libthr/thread/thr_stack.c:129
>> 129 if (size % _thr_page_size !=3D 0)
>> (gdb)=20
>> 130 size =3D ((size / _thr_page_size) + 1) *
>> (gdb)=20
>> 129 if (size % _thr_page_size !=3D 0)
>> (gdb)=20
>> 130 size =3D ((size / _thr_page_size) + 1) *
>> (gdb)=20
>> 0x20112ef8 130 size =3D ((size / _thr_page_size) + 1) *
>> (gdb)=20
>> 0x20116b60 in ?? () from /lib/libthr.so.3
>> (gdb)=20
>> 0x20116b64 in ?? () from /lib/libthr.so.3
>> (gdb)=20
>> 0x20116b68 in ?? () from /lib/libthr.so.3
>> (gdb)=20
>> 0x20116760 in ?? () from /lib/libthr.so.3
>> (gdb)=20
>> 0x20116764 in ?? () from /lib/libthr.so.3
>> (gdb)=20
>> 0x20116768 in ?? () from /lib/libthr.so.3
>> (gdb)=20
>> 0x2011676c in ?? () from /lib/libthr.so.3
>> (gdb)=20
>> _rtld_bind_start () at =
/home/pkgbuild/worktrees/main/libexec/rtld-elf/arm/rtld_start.S:78
>> 78 stmdb sp!,{r0-r5,sl,fp}
>> (gdb) si
>> 80 sub r1, ip, lr /* r1 =3D 4 * (n + 1) */
>> (gdb)=20
>> 81 sub r1, r1, #4 /* r1 =3D 4 * n */
>> (gdb)=20
>> 82 add r1, r1, r1 /* r1 =3D 8 * n */
>> (gdb)=20
>> 84 ldr r0, [lr, #-4] /* get obj ptr from GOT[1] */
>> (gdb)=20
>> 85 mov r4, ip /* save GOT location */
>> (gdb)=20
>> 87 mov r5, sp /* Save the stack pointer */
>> (gdb)=20
>> 88 bic sp, sp, #7 /* Align the stack pointer */
>> (gdb)=20
>> _rtld_bind_start () at =
/home/pkgbuild/worktrees/main/libexec/rtld-elf/arm/rtld_start.S:89
>> 89 bl _rtld_bind /* Call the binder */
>>=20
>>=20
>> I have not checked for other .symtab entry problems.
>>=20
>> Nor have I figured out why the installed materials are
>> different for Symbol table '.symtab' . So this is not
>> yet root-cause information.


I know why. My personal FreeBSD builds have long had my
equivalents of src.conf (under normal naming) contain:

#
# Avoid stripping but do not control host -g status as well:
DEBUG_FLAGS+=3D

This likely replaces my earlier -mcpu=3Dcortex-a7 hypothesis
for what a systematic difference might be that could
contribute to the personal builds not having the problem.


=3D=3D=3D
Mark Millard
marklmi at yahoo.com




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?>