Pour polenta into 2 9-inch cake rounds. Let sit until it firms up.
Adjust oven rack to upper-middle position and heat oven to 500 degrees. Lay eggplant slices on a large (18- by 12-inch) rimmed baking sheet. Brush one side with olive oil and sprinkle with salt and pepper. Turn slices over and repeat on other side. Place eggplant in preheating oven and roast until gold brown, 20 to 25 minutes.
Meanwhile, bring tomato sauce, rosemary, and olives to simmer in a medium saucepan until t it mounds on a spoon, about 10 minutes.
Layer in the following order: 1 polenta round left in the pan, 1 scant cup tomato sauce, 1/2 of the eggplant, 1/2 cup tomato sauce, 1/2 cup feta and 2 tablespoons pecorino, the second polenta round, 1 scant cup tomato sauce, remaining eggplant, tomato sauce, and cheeses.
Bake until cheeses are brown and tomato sauce is bubbly, about 30 minutes. Let stand a few minutes to set, cut into 6 portions, and serve.