The EPUB 2 spec provides for this feature via a
pageList in the NCX.
Edit: And Adobe has a similar way of doing it using a page-map. However both rely on the publisher providing the page data, so the ereader needs to have a way to synthesise the page numbers if the publisher has forgotten to include them. Most publishers don't bother to provide a pageList or page-map, so what you see in the Kobo ereaders is usually the synthetic page numbers.