107d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath/* Return entry PC attribute of DIE.
207d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath   Copyright (C) 2003, 2005 Red Hat, Inc.
3de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard   This file is part of elfutils.
407d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath
5de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard   This file is free software; you can redistribute it and/or modify
6de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard   it under the terms of either
707d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath
8de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard     * the GNU Lesser General Public License as published by the Free
9de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard       Software Foundation; either version 3 of the License, or (at
10de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard       your option) any later version
11de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard
12de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard   or
13de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard
14de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard     * the GNU General Public License as published by the Free
15de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard       Software Foundation; either version 2 of the License, or (at
16de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard       your option) any later version
17de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard
18de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard   or both in parallel, as here.
19de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard
20de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard   elfutils is distributed in the hope that it will be useful, but
21361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper   WITHOUT ANY WARRANTY; without even the implied warranty of
22361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper   General Public License for more details.
24361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper
25de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard   You should have received copies of the GNU General Public License and
26de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard   the GNU Lesser General Public License along with this program.  If
27de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard   not, see <http://www.gnu.org/licenses/>.  */
2807d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath
2907d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath#ifdef HAVE_CONFIG_H
3007d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath# include <config.h>
3107d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath#endif
3207d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath
3307d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath#include <dwarf.h>
3407d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath#include "libdwP.h"
3507d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath
3607d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath
3707d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrathint
381ccdfb683ad6c7e59793136c3a657ddf131cafd1Mark Wielaarddwarf_entrypc (Dwarf_Die *die, Dwarf_Addr *return_addr)
3907d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath{
4007d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath  Dwarf_Attribute attr_mem;
4107d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath
4207d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath  return INTUSE(dwarf_formaddr) (INTUSE(dwarf_attr) (die, DW_AT_entry_pc,
4307d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath						     &attr_mem)
4407d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath				 ?: INTUSE(dwarf_attr) (die, DW_AT_low_pc,
4507d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath							&attr_mem),
4607d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath				 return_addr);
4707d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath}
4807d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrathINTDEF(dwarf_entrypc)
49