Melt the butter in a large, heavy saucepan. Add the onion and cook over moderately high heat, stirring, until lightly browned, 6 to 7 minutes. Add the corn and garlic and cook, stirring, until the corn is lightly browned, about 5 minutes. Add the stock and simmer until the corn is tender, about 15 minutes. Season with salt and pepper.