Middle English stok, from Old English stocc "stump, wooden post, stake; trunk of a living tree; log," also "pillory" (usually plural, stocks), from Proto-Germanic *stauk- "tree trunk" (source also of Old Norse stokkr "block of wood, trunk of a tree," Old Saxon, Old Frisian stok, Middle Dutch stoc "tree trunk, stump," Dutch stok "stick, cane," Old High German stoc "tree trunk, stick," German Stock "stick, cane;" also Dutch stuk, German Stück "piece").
This is said to be from an extended form of PIE root *(s)teu- (1) "to push, stick, knock, beat" (see steep (adj.)), but Boutkan considers that instead it is "probably" from an extended form of the root *sta- "to stand, make or be firm."
In old use often paired alliteratively with stone (n.). With specific technical senses based on the idea of "principal supporting part" of a tool or weapon (to which others were affixed), such as "block from which a bell is hung," "gun carriage" (both late 15c.).
The sense of "part of a rifle held against the shoulder" is from 1540s. Stock, lock, and barrel "the whole of a thing" is recorded from 1817.
The meaning "line of descent, ancestry" is from late 12c.; that of "original progenitor of a family" is late 14c.; figurative uses of the "trunk of a living tree" sense (compare the notion in family tree and the family sense of stem (n.)).
In comparisons, the meaning "person as dull and senseless as a block or log" is from c. 1300; hence "a dull recipient of action or notice" (1510s), as in laughing-stock and compare butt (n.3).