What the profile is drawn from
The altitude series in the file — every point's height, in order. From that come two things: the shape of the profile, and the elevation gain, which is a sum of every climb above a small threshold. The threshold matters: count every metre of barometer wobble and a flat ride climbs a mountain. What elevation gain actually counts goes through it, and why Strava and Garmin disagree explains the different numbers you have seen for the same ride.
When the profile is left out
If the file has no altitude, or the altitude is flat noise, the viewer draws the route without a profile rather than drawing a lie. Phones without a barometer and some watches in the wrong mode produce exactly that. The route is still right; the height was never recorded.
Drift
A barometric altimeter drifts with the weather over a long day, so a loop can come home 100 metres below where it started without descending. The profile band on a print is drift-corrected so its shape is honest; the gain figure printed under the line comes from the file's own summary when it has one. The elevation profile tells you more than the map is the longer read.