I take the stance that the rock upon which Jesus is going to build his church to be referring basically to Christ who is presented as the rock in the OT and also in Matthew and elsewhere in the NT. Two in Matthew include: Mat 7:24 "Everyone then who hears these words of mine and does them will be like a wise man who built his house on the rock." and Mat 21:42 Jesus said to them, "Have you never read in the Scriptures: "'The stone that the builders rejected has become the cornerstone; this was the Lord's doing, and it is marvelous in our eyes'?" Some have seen it as referring to Peter's confession of Christ but to me it is all the same and need not be separated. Christ and the gospel of his work is the rock; we don't need to try to separate him from his work of redemption. This is why in Eph. 2 the prophets and Apostles are seen to be the church's foundation because it is their witness of Christ in the Bible upon which the church is built. So the Lord is actively building the church and he builds it by the proclamation of his Word which is all about him.
So I think Jesus by stating the fact that Peter's name means rock and then referring to himself as a rock is using a pun of sorts, a play on words, to teach of the foundation of the church. If he meant that he was going to build the church on Peter's authority as a pope then he said it in such a way that even the disciples didn't get it and it is clear from the rest of the NT that they never got it. Even Peter in 1 Pet. 2 refers to Jesus as the rock and never mentions himself as having anything to do with someone's salvation either in Acts or in his epistles.
This brings us then to the statement about the gates of Hell. The context is how the church is being built on the Rock and so it seems his next statement is making it clear that when someone takes a stand on Christ there is no worry of being shaken off. In fact Christ is the only sure foundation there is for anyone to cast their soul upon. I believe the context is all about the gospel of salvation in Christ which will help us understand this statement.
For some reason a popular interpretation has been that the church (God's people) will be able to withstand Satan's onslaughts and not be overcome by him. While this certainly has biblical support I do not think this is what Jesus is referring to. Gates are defensive weapons, not offensive ones. Cities don't move around and cast their gates at other cities; they keep enemies out. So whatever Jesus is saying he is suggesting that the church is attacking the gates of Hell and that it will be able to break through. OK, so what does that mean?
The term "gates of Hell" was an ancient way of referring to death When one died he was said to pass through the gates of Hell in that he went to the place of the dead. Spiritually, of course, we are all born in the place of death and need to be delivered from it. So as the church proclaim's Christ as witnessed in the Scriptures God delivers his people from the place of death. All men are born in the bondage of sin and death and it is only through the gospel that they can be delivered. So Jesus is proclaiming the victory of the cross even before he gets there. Later as he sends his disciples into all the world to seek and to save that which is lost by preaching the gospel, they can go with confidence that God's Word will accomplish just what God wills it to because the gates of Hell cannot keep the Holy Spirit from breaking in and delivering the elect because our God is too powerful.
There are an amazing amount of passages in the NT alone that refer to this; here are but two: Heb 2:14 Since therefore the children share in flesh and blood, he himself likewise partook of the same things, that through death he might destroy the one who has the power of death, that is, the devil. and 2Ti 1:10 and which now has been manifested through the appearing of our Savior Christ Jesus, who abolished death and brought life and immortality to light through the gospel. All this reminds me of the old hymn we sing, "Victory in Jesus"; at the end of the day I have to believe that Jesus is referring to himself in Matthew 16.