In this paper, a new spectrum sharing model referred to as riding on the primary (ROP) is proposed for wireless-powered IoT devices with ambient backscatter communication capabilities. The key idea of ROP is that the secondary transmitter harvests energy from the primary signal, then modulates its information bits to the primary signal, and reflects the modulated signal to the secondary receiver without violating the primary system's interference requirement. Compared with the conventional spectrum sharing model, the secondary system in the proposed ROP not only utilizes the spectrum of the primary system but also takes advantage of the primary signal to harvest energy and to carry its information. In this paper, we investigate the performance of such a spectrum sharing system under fading channels. To be specific, we maximize the ergodic capacity of the secondary system by jointly optimizing the transmit power of the primary signal and the reflection coefficient of the secondary ambient backscatter. Different (ideal/practical) energy consumption models, different (peak/average) transmit power constraints, different types (fixed/dynamically adjustable) reflection coefficient, different primary system's interference requirements (rate/outage) are considered. Optimal power allocation and reflection coefficient are obtained for each scenario.