Oxford Annotated Bible note for 2 Samuel 8:17: Ahimelech the son of Abiathar should perhaps be reversed (1 Sam.22.20), though is is also possible that Abiathar
had a son Ahimelech who acted in place of his aged father (1 Chr.18.16; 24.3,6,31).
Biblically Correct answer: Abiathar was the son of Ahimelech
I'll go with what the Oxford Annotated Bible said was most likely.