Yes, this functionality is required by law and is done at the chipset firmware level these days. And even before phones supported this, it was done by triangulation at the carriers towers.
The cellular modem usually has GPS and SMS capabilities integrated in one hardware package.