Steven Laitz calls this a common-tone diminished seventh chord, which is labeled "c.t.o7 to distinguish it from other uses of diminished chords.1 (See also Wikipedia's Diminshed Seventh chord: other functions.) Its function is to "maintain the root of the harmony they extend".2 Here is a reproduction of Laitz's Example 35.17A, which illustrates the process:
T:Steven Laitz, The Complete Musician, 2008
T:Example 35.17A (p. 820)
%%score V1 (V2 V3)
[V:V1] y E y E- y E
[V:V2 clef=bass] y [A,C] y [=G,C] y [^G,D]
[V:V3 clef=bass] "_A:"y A,, y ^A,, y B,,
s: I c.t.o7/V V
1 Laitz, Steven G, 2008, The complete musician, New York: Oxford University Press, p. 820. Laitz is not alone in this. For example, see Aldwell, Edward, and Carl Schachter, 1989, Harmony and voice leading, Fort Worth: Harcourt Brace Jovanovich College Publishers, pp. 516-519.
2 Ibid. (Laitz's italics).