There's actually considerable debate and ongoing research on exactly when and how gender roles are acquired, and how much they can change over the lifespan. I've linked Gender Roles: A Sociological Perspective, which is a standard text in the sociology of gender and seems like it might be a good place to start.
There are a number of different theories of gender role acquisition, which vary in how much they ascribe gender development to social environment versus genetics. We do have experimental evidence that some concept of gender roles is formed very early, well before speech, which suggests some genetic component. But clearly some gender roles vary substantially between cultures, so there must be a component due to social environment as well. The idea that gender roles are imprinted at a very young age and henceforth are very difficult to change---akin to how language is imprinted---could account for both phenomena, but is by no means universally accepted.
As for the pride/shame issue, be careful: almost any violation of social norms is going to trigger feelings of shame, regardless of how those social norms were learned. I know that the proper placement of salad forks is absolutely a learned behavior, usually acquired in adulthood; but I'd still feel ashamed if I did it wrong when arranging an important business dinner. What's important is not how I learned the norm, but how I perceive others will react if I violate it.