Both nouns are genitive in مَرَرْتُ بِالْعَصَا وَغُلَامِي.

Noun Case Class 7 — Maqṣūr and Nouns with Possessive Yāʾ