Page MenuHomeFreeBSD

Factor out retrieving the interpreter path from the main ELF loader routine.
ClosedPublic

Authored by trasz on Mar 26 2019, 3:42 PM.
Tags
None
Referenced Files
Unknown Object (File)
Dec 20 2023, 2:22 AM
Unknown Object (File)
Nov 22 2023, 10:28 PM
Unknown Object (File)
Nov 22 2023, 10:27 PM
Unknown Object (File)
Nov 22 2023, 10:02 PM
Unknown Object (File)
Nov 22 2023, 8:58 PM
Unknown Object (File)
Nov 19 2023, 10:15 AM
Unknown Object (File)
Nov 14 2023, 5:11 AM
Unknown Object (File)
Nov 13 2023, 2:13 PM
Subscribers

Details

Summary

Factor out retrieving the interpreter path from the main ELF
loader routine.

One small difference is that it no longer errors out if there
are multiple PT_INTERP sections; it just uses the first one.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 23328
Build 22358: arc lint + arc unit

Event Timeline

If you only move some parts of the case PT_INTERP into the helper, you can 1. avoid one more pass over phdrs 2. easily keep the logic to error on more than one interpreter.

Also I do not completely like the removal of the interp_name_len argument from the get_brandinfo args.

sys/kern/imgact_elf.c
285

If you insist on doing this arg removal, at least write this code as

interp_name_len = interp != NULL ? strlen(interp) : 0;

Kib's suggestions.

Updating D19715: Factor out retrieving the interpreter path from the main ELF

loader routine.

sys/kern/imgact_elf.c
901

Add assertions: phdr type is PT_INTERP, vp is exclusively locked.

902

curthread is used only once, it seems. I do not see a need for td.

930

If you restore the 'else' clause, then *interpp = interp; return (0); can be left once in the end of the function.

Improve.

Updating D19715: Factor out retrieving the interpreter path from the main ELF

loader routine.

trasz added inline comments.
sys/kern/imgact_elf.c
930

I find the current version easier to read, to be honest.

kib added inline comments.
sys/kern/imgact_elf.c
930

For me (the reader) it is reverse. I need to understand that all successful exit paths satisfy the function interface, and single success-exit with non-duplicated code makes it easier to see.

I would not stop you from committing this due to the rearrangement of three lines, but I prefer the described version.

This revision is now accepted and ready to land.Mar 27 2019, 4:41 PM
This revision was automatically updated to reflect the committed changes.