Nowadays most of that is provided through the permissions you accept when you download an app to your mobile device. Any app that needs internet access, phone identity and read contacts permissions are basically allowed to harvest any data on that phone.
So for example: If your friend has your number and downloads an app with those permissions, they are basically giving away your info.