We show using the entropy function formalism developed by Sen cite{Sen:2005wa} that the boundary term which arises from the Einstein-Hilbert action is sufficient to yield the Bekenstein-Hawking entropy of a static extremal black hole which is asymptotically flat. However, for asymptotically $AdS$ black holes, the bulk term also plays an important role due to the presence of the cosmological constant. Further, we show that for extremal rotating black holes, both the boundary and the bulk terms contribute non-vanishing pieces to the entropy.