OpenBSD CVS

CVS log for src/lib/csu/boot.h


[BACK] Up to [local] / src / lib / csu

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.35 / (download) - annotate - [select for diffs], Sat Nov 18 16:26:15 2023 UTC (6 months, 3 weeks ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_7_5_BASE, OPENBSD_7_5, HEAD
Changes since 1.34: +2 -2 lines
Diff to previous 1.34 (colored)

crt0 uses a helper function in a MD src/libexec/ld.so .h file (rather than
reproducing the relevant defines and code in a different place) to perform
minor relocations.  If things go very wrong, it would call _dl_exit() --
a locally defined crt0 function which is syscall exit(2).  We don't need
to call exit(2) for this obscure case which doesn't happen and provides no
debugging information. An 'abort' is going to provide better information.
So let's change the function name to _dso_abort() and make it a single
illegal instruction.
ok guenther

Revision 1.34 / (download) - annotate - [select for diffs], Fri Oct 21 18:14:09 2022 UTC (19 months, 2 weeks ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_7_4_BASE, OPENBSD_7_4, OPENBSD_7_3_BASE, OPENBSD_7_3
Changes since 1.33: +5 -2 lines
Diff to previous 1.33 (colored)

static binaries self-mprotect their relro in crt0.  mimmutable() also works
here.
ok kettenis

Revision 1.33 / (download) - annotate - [select for diffs], Wed Jan 12 21:41:06 2022 UTC (2 years, 4 months ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_7_2_BASE, OPENBSD_7_2, OPENBSD_7_1_BASE, OPENBSD_7_1
Changes since 1.32: +7 -7 lines
Diff to previous 1.32 (colored)

Lift the '#ifdef RCRT0' conditional out of boot*.h to crt0.c

Prep for dropping #includes from archdep.h: pull in <machine/reloc.h>
and declare _dl_exit() in boot*.h

ok kettenis@

Revision 1.32 / (download) - annotate - [select for diffs], Tue Nov 16 02:46:46 2021 UTC (2 years, 6 months ago) by guenther
Branch: MAIN
Changes since 1.31: +16 -26 lines
Diff to previous 1.31 (colored)

Sync boot.h with ld.so's boot.c, getting rid of struct boot_dyn,
only initializing the variables we need to, and switching to a
"while < end-of-array" style for DT_REL/RELA processing

ok drahn@ kettenis@

Revision 1.31 / (download) - annotate - [select for diffs], Sun Nov 14 00:45:38 2021 UTC (2 years, 6 months ago) by guenther
Branch: MAIN
Changes since 1.30: +5 -66 lines
Diff to previous 1.30 (colored)

Split out the hppa and mips64 versions of boot.h similar to how I
split ld.so/boot.c in 2019:
 * delete extraneous #includes
 * delete jmprel handling on non-hppa
 * delete RELOC_GOT() and DT_PROC bits on non-mips64

ok visa@

Revision 1.30 / (download) - annotate - [select for diffs], Fri May 10 13:29:21 2019 UTC (5 years, 1 month ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_7_0_BASE, OPENBSD_7_0, OPENBSD_6_9_BASE, OPENBSD_6_9, OPENBSD_6_8_BASE, OPENBSD_6_8, OPENBSD_6_7_BASE, OPENBSD_6_7, OPENBSD_6_6_BASE, OPENBSD_6_6
Changes since 1.29: +11 -3 lines
Diff to previous 1.29 (colored)

ld.so boot cleanup support:
 - put functions and data which are only used before calling the executable's
   start function into their own page-aligned segments for unmapping
   (only done on amd64, arm64, armv7, powerpc, and sparc64 so far)
 - pass .init_array and .preinit_array functions an addition argument which
   is a callback to get a structure which includes a function that frees
   the boot text and data
 - sometimes delay doing RELRO processing: for a shared-object marked
   DF_1_INITFIRST do it after the object's .init_array, for the executable
   do it after the .preinit_array
 - improve test-ld.so to link against libpthread and trigger its initialization
   late
libc changes to use this will come later

ok kettenis@

Revision 1.29 / (download) - annotate - [select for diffs], Thu Nov 22 21:37:29 2018 UTC (5 years, 6 months ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_6_5_BASE, OPENBSD_6_5
Changes since 1.28: +1 -33 lines
Diff to previous 1.28 (colored)

Make alpha less special: _dl_boot_bind() is written to complete
relocation of ld.so's GOT without using it, so _reloc_alpha_got()
merely made the call to _dl_boot_bind() from asm simpler...while
itself being a call that required special handling.

diff and muild baking by miod@
ok guenther@

Revision 1.28 / (download) - annotate - [select for diffs], Sun Jan 29 22:31:09 2017 UTC (7 years, 4 months ago) by chl
Branch: MAIN
CVS Tags: OPENBSD_6_4_BASE, OPENBSD_6_4, OPENBSD_6_3_BASE, OPENBSD_6_3, OPENBSD_6_2_BASE, OPENBSD_6_2, OPENBSD_6_1_BASE, OPENBSD_6_1
Changes since 1.27: +1 -3 lines
Diff to previous 1.27 (colored)

remove unused variables

ok krw@ guenther@

Revision 1.27 / (download) - annotate - [select for diffs], Mon Jan 2 15:25:50 2017 UTC (7 years, 5 months ago) by kettenis
Branch: MAIN
Changes since 1.26: +1 -10 lines
Diff to previous 1.26 (colored)

Remove the (now unused) code to determine the page size.  Also get rid of
the extern declaration of __got_{start,end}.

ok guenther@

Revision 1.26 / (download) - annotate - [select for diffs], Sat Dec 24 16:00:35 2016 UTC (7 years, 5 months ago) by kettenis
Branch: MAIN
Changes since 1.25: +2 -2 lines
Diff to previous 1.25 (colored)

Replace return by break; requested by guenther@

Revision 1.25 / (download) - annotate - [select for diffs], Sat Dec 24 15:55:07 2016 UTC (7 years, 5 months ago) by kettenis
Branch: MAIN
Changes since 1.24: +1 -11 lines
Diff to previous 1.24 (colored)

Remove code that reprotects the GOT based on the __got_start and __got_end
symbols.  Either the PT_LOAD RWX->RX case ot PT_GNU_RELRO should cover this
already for anything we care about.  And lld, the llvm linker, doesn't emit
the __got_start and __got_end symbols and there are good reasons to leave it
that way.

ok guenther@

Revision 1.24 / (download) - annotate - [select for diffs], Mon Dec 19 18:30:50 2016 UTC (7 years, 5 months ago) by krw
Branch: MAIN
Changes since 1.23: +2 -3 lines
Diff to previous 1.23 (colored)

A couple more unused variables.

tweak & ok kettenis@

Revision 1.23 / (download) - annotate - [select for diffs], Thu Sep 1 09:33:30 2016 UTC (7 years, 9 months ago) by tedu
Branch: MAIN
Changes since 1.22: +2 -2 lines
Diff to previous 1.22 (colored)

retire sparc

Revision 1.22 / (download) - annotate - [select for diffs], Mon Aug 8 22:05:26 2016 UTC (7 years, 10 months ago) by guenther
Branch: MAIN
Changes since 1.21: +24 -8 lines
Diff to previous 1.21 (colored)

Look for a PT_GNU_RELRO section and, if present, mprotect that range
instead of the [__got_start, __got_end) range.

Also, instead of mprotecting the [__plt_start, __plt_end) range,
just scan for sections which are both writable and executable and
mprotect them to read-only.  (This part was stolen from kettenis@)

ok kettenis@

Revision 1.21 / (download) - annotate - [select for diffs], Sun Aug 7 02:44:00 2016 UTC (7 years, 10 months ago) by guenther
Branch: MAIN
Changes since 1.20: +1 -6 lines
Diff to previous 1.20 (colored)

Teach mips64 to pass &_DYNAMIC to _dl_boot_bind().

mips64be testing by deraadt@

Revision 1.20 / (download) - annotate - [select for diffs], Sun Aug 7 02:34:52 2016 UTC (7 years, 10 months ago) by guenther
Branch: MAIN
Changes since 1.19: +2 -4 lines
Diff to previous 1.19 (colored)

alpha already calculates &_DYNAMIC for the _reloc_alpha_got() call, so
save that and pass it to _dl_boot_bind() too

Revision 1.19 / (download) - annotate - [select for diffs], Sun Aug 7 02:30:55 2016 UTC (7 years, 10 months ago) by guenther
Branch: MAIN
Changes since 1.18: +2 -2 lines
Diff to previous 1.18 (colored)

Teach i386 to pass &_DYNAMIC to _dl_boot_bind()

Revision 1.18 / (download) - annotate - [select for diffs], Sun Aug 7 02:30:04 2016 UTC (7 years, 10 months ago) by guenther
Branch: MAIN
Changes since 1.17: +2 -2 lines
Diff to previous 1.17 (colored)

Psych: amd64 has been passing &_DYNAMIC to _dl_boot_bind() for 19 months

Revision 1.17 / (download) - annotate - [select for diffs], Sun Aug 7 02:28:12 2016 UTC (7 years, 10 months ago) by guenther
Branch: MAIN
Changes since 1.16: +4 -5 lines
Diff to previous 1.16 (colored)

Flip the #ifdef logic: amd64, i386, and mips64 were the only static PIE
archs using the #else case

Revision 1.16 / (download) - annotate - [select for diffs], Tue Jul 5 00:44:41 2016 UTC (7 years, 11 months ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_6_0_BASE, OPENBSD_6_0
Changes since 1.15: +1 -2 lines
Diff to previous 1.15 (colored)

Missed a reference to dl_prebind.h

problem noted by Andrew Ngo (andrew.ngo (at) gmail.com)

Revision 1.15 / (download) - annotate - [select for diffs], Sat Mar 12 23:28:47 2016 UTC (8 years, 3 months ago) by guenther
Branch: MAIN
Changes since 1.14: +8 -1 lines
Diff to previous 1.14 (colored)

Call mprotect() via its hidden _lib_mprotect alias to avoid accidental
overriding

ok deraadt@ kettenis@

Revision 1.14 / (download) - annotate - [select for diffs], Sun Dec 6 23:36:12 2015 UTC (8 years, 6 months ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_5_9_BASE, OPENBSD_5_9
Changes since 1.13: +72 -133 lines
Diff to previous 1.13 (colored)

Simplify the relocation code for the ld.so bootstrap and static pie: track
just the dynamic tags are needed instead of reusing the generic elf_object_t
structure.

testing and feedback from miod@
ok kettenis@

Revision 1.13 / (download) - annotate - [select for diffs], Sat Sep 19 20:11:22 2015 UTC (8 years, 8 months ago) by kettenis
Branch: MAIN
Changes since 1.12: +10 -2 lines
Diff to previous 1.12 (colored)

Make sure we set PROT_EXEC on the GOT for BSS-PLT binaries on powerpc.

ok guenther@

Revision 1.12 / (download) - annotate - [select for diffs], Mon Aug 17 17:13:58 2015 UTC (8 years, 9 months ago) by kettenis
Branch: MAIN
Changes since 1.11: +1 -3 lines
Diff to previous 1.11 (colored)

Do not include os-note-elf.h here, otherwise we end up with duplicate OS notes
in our binaries.

ok miod@

Revision 1.11 / (download) - annotate - [select for diffs], Fri Jul 3 11:17:25 2015 UTC (8 years, 11 months ago) by miod
Branch: MAIN
CVS Tags: OPENBSD_5_8_BASE, OPENBSD_5_8
Changes since 1.10: +3 -2 lines
Diff to previous 1.10 (colored)

static pie support for sparc.

Revision 1.10 / (download) - annotate - [select for diffs], Fri Jan 16 06:47:03 2015 UTC (9 years, 4 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_5_7_BASE, OPENBSD_5_7
Changes since 1.9: +1 -2 lines
Diff to previous 1.9 (colored)

<sys/param.h> is not needed here either.
ok guenther millert doug

Revision 1.9 / (download) - annotate - [select for diffs], Mon Dec 29 20:18:20 2014 UTC (9 years, 5 months ago) by kettenis
Branch: MAIN
Changes since 1.8: +2 -2 lines
Diff to previous 1.8 (colored)

Make the PLT read-only on powerpc as well.

ok kurt@

Revision 1.8 / (download) - annotate - [select for diffs], Sat Dec 27 13:17:51 2014 UTC (9 years, 5 months ago) by kettenis
Branch: MAIN
Changes since 1.7: +36 -2 lines
Diff to previous 1.7 (colored)

Static PIE support for alpha.

This adds alpha-specific first-pass GOT relocation code to boot.h.
The assembly code is pure magic.  The numeric register
names don't make it easier to understand (or compare with the
equivalent ld.so code).  Unfortunately the assembler only understands
a few symbolic register names.

Renames the crt0.o entry point to __start.  Our compiler was already using
__start and the linker will soon follow.

ok kurt@

Revision 1.7 / (download) - annotate - [select for diffs], Thu Dec 25 21:38:45 2014 UTC (9 years, 5 months ago) by kurt
Branch: MAIN
Changes since 1.6: +2 -2 lines
Diff to previous 1.6 (colored)

Use archdep.h GOT_PERMS define for mprotect of GOT. okay kettenis@

Revision 1.6 / (download) - annotate - [select for diffs], Wed Dec 24 14:04:09 2014 UTC (9 years, 5 months ago) by kurt
Branch: MAIN
Changes since 1.5: +21 -6 lines
Diff to previous 1.5 (colored)

Expand Elf_Rel relocations to include DT_JMPREL. Inspect DT_PLTREL value
to determine if DT_JMPREL relocations are REL or RELA and conditionally
perform DT_JMPREL in either REL or RELA as needed (idea from kettenis@).
Remove unneeded i386 RELA implementation. i386 static pie working now.

okay kettenis@

Revision 1.5 / (download) - annotate - [select for diffs], Wed Dec 24 08:58:46 2014 UTC (9 years, 5 months ago) by kettenis
Branch: MAIN
Changes since 1.4: +2 -2 lines
Diff to previous 1.4 (colored)

Fix previos.  Pointed out by kurt@.

Revision 1.4 / (download) - annotate - [select for diffs], Tue Dec 23 20:38:20 2014 UTC (9 years, 5 months ago) by kettenis
Branch: MAIN
Changes since 1.3: +11 -5 lines
Diff to previous 1.3 (colored)

Use the page size passed by the kernel in the Auxilliary Vector to handle
architectures with variable page size.

Revision 1.3 / (download) - annotate - [select for diffs], Tue Dec 23 16:45:04 2014 UTC (9 years, 5 months ago) by kettenis
Branch: MAIN
Changes since 1.2: +23 -1 lines
Diff to previous 1.2 (colored)

Make sure the GOT and PLT are not writable.

Note that ommitting PROT_EXEC for the PLT is deliberate; static PIE
binaries should never actually hit the PLT.

We're still debating what to do when mprotect(2) fails.  But that is no
excuse not to at least attempt to fix things up.

ok deraadt@

Revision 1.2 / (download) - annotate - [select for diffs], Mon Dec 22 13:32:51 2014 UTC (9 years, 5 months ago) by kettenis
Branch: MAIN
Changes since 1.1: +7 -5 lines
Diff to previous 1.1 (colored)

When skipping a relocation because the referenced symbol is undefined, make
sure we move on to the next relocation entry.

While there, also skip relocations for REL architectures.

Revision 1.1 / (download) - annotate - [select for diffs], Mon Dec 22 03:51:08 2014 UTC (9 years, 5 months ago) by kurt
Branch: MAIN

Introduce new csu0 variant for -static -pie binaries to use called
rcsu0.o where the initial 'r' is for relocatable. rcsu0.o performs
self-relocation on static pie binaries by calling a slightly modified
copy of ld.so's _dl_boot_bind() in boot.h.

The first arch implementatation is also included for amd64 where
__start calls _dl_boot_bind() and then calls ___start(). Includes
parts from kettenis@ to help get R_X86_64_64 relocations working
and proper handling for undefined weak symbols.

This is the first part of several to get static pie self-relocating
binaries working. binutils, gcc and kernel changes are forthcoming
to complete the solution, then per-arch implementations are needed
for MD_RCRT0_START in csu.

okay kettenis@ pascal@ deraadt@

This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.