/* Alpha specific symbolic name handling.
- Copyright (C) 2002-2011 Red Hat, Inc.
+ Copyright (C) 2002-2012 Red Hat, Inc.
- This file is part of Red Hat elfutils.
+ This file is part of elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
- Red Hat elfutils is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by the
- Free Software Foundation; version 2 of the License.
+ This file is free software; you can redistribute it and/or modify
+ it under the terms of either
- Red Hat elfutils is distributed in the hope that it will be useful, but
+ * the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 3 of the License, or (at
+ your option) any later version
+
+ or
+
+ * the GNU General Public License as published by the Free
+ Software Foundation; either version 2 of the License, or (at
+ your option) any later version
+
+ or both in parallel, as here.
+
+ elfutils is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
/* Arm specific symbolic name handling.
- Copyright (C) 2002-2009 Red Hat, Inc.
+ Copyright (C) 2002-2010 Red Hat, Inc.
- This file is part of Red Hat elfutils.
+ This file is part of elfutils.
- Red Hat elfutils is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by the
- Free Software Foundation; version 2 of the License.
+ This file is free software; you can redistribute it and/or modify
+ it under the terms of either
- Red Hat elfutils is distributed in the hope that it will be useful, but
+ * the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 3 of the License, or (at
+ your option) any later version
+
+ or
+
+ * the GNU General Public License as published by the Free
+ Software Foundation; either version 2 of the License, or (at
+ your option) any later version
+
+ or both in parallel, as here.
+
+ elfutils is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
/* i386 specific symbolic name handling.
- Copyright (C) 2000, 2001, 2002, 2005 Red Hat, Inc.
+ Copyright (C) 2000-2010 Red Hat, Inc.
- This file is part of Red Hat elfutils.
+ This file is part of elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2000.
- Red Hat elfutils is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by the
- Free Software Foundation; version 2 of the License.
+ This file is free software; you can redistribute it and/or modify
+ it under the terms of either
- Red Hat elfutils is distributed in the hope that it will be useful, but
+ * the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 3 of the License, or (at
+ your option) any later version
+
+ or
+
+ * the GNU General Public License as published by the Free
+ Software Foundation; either version 2 of the License, or (at
+ your option) any later version
+
+ or both in parallel, as here.
+
+ elfutils is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
/* IA-64 specific symbolic name handling.
- Copyright (C) 2002-2009 Red Hat, Inc.
+ Copyright (C) 2002-2010 Red Hat, Inc.
- This file is part of Red Hat elfutils.
+ This file is part of elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
- Red Hat elfutils is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by the
- Free Software Foundation; version 2 of the License.
+ This file is free software; you can redistribute it and/or modify
+ it under the terms of either
- Red Hat elfutils is distributed in the hope that it will be useful, but
+ * the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 3 of the License, or (at
+ your option) any later version
+
+ or
+
+ * the GNU General Public License as published by the Free
+ Software Foundation; either version 2 of the License, or (at
+ your option) any later version
+
+ or both in parallel, as here.
+
+ elfutils is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
/* PPC64 specific symbolic name handling.
- Copyright (C) 2004, 2005 Red Hat, Inc.
+ Copyright (C) 2004-2010 Red Hat, Inc.
- This file is part of Red Hat elfutils.
+ This file is part of elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2004.
- Red Hat elfutils is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by the
- Free Software Foundation; version 2 of the License.
+ This file is free software; you can redistribute it and/or modify
+ it under the terms of either
- Red Hat elfutils is distributed in the hope that it will be useful, but
+ * the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 3 of the License, or (at
+ your option) any later version
+
+ or
+
+ * the GNU General Public License as published by the Free
+ Software Foundation; either version 2 of the License, or (at
+ your option) any later version
+
+ or both in parallel, as here.
+
+ elfutils is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
/* PPC specific symbolic name handling.
- Copyright (C) 2004, 2005, 2007 Red Hat, Inc.
+ Copyright (C) 2004-2010 Red Hat, Inc.
- This file is part of Red Hat elfutils.
+ This file is part of elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2004.
- Red Hat elfutils is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by the
- Free Software Foundation; version 2 of the License.
+ This file is free software; you can redistribute it and/or modify
+ it under the terms of either
- Red Hat elfutils is distributed in the hope that it will be useful, but
+ * the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 3 of the License, or (at
+ your option) any later version
+
+ or
+
+ * the GNU General Public License as published by the Free
+ Software Foundation; either version 2 of the License, or (at
+ your option) any later version
+
+ or both in parallel, as here.
+
+ elfutils is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
/* S/390-specific symbolic name handling.
- Copyright (C) 2005 Red Hat, Inc.
+ Copyright (C) 2005-2010 Red Hat, Inc.
- This file is part of Red Hat elfutils.
+ This file is part of elfutils.
- Red Hat elfutils is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by the
- Free Software Foundation; version 2 of the License.
+ This file is free software; you can redistribute it and/or modify
+ it under the terms of either
- Red Hat elfutils is distributed in the hope that it will be useful, but
+ * the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 3 of the License, or (at
+ your option) any later version
+
+ or
+
+ * the GNU General Public License as published by the Free
+ Software Foundation; either version 2 of the License, or (at
+ your option) any later version
+
+ or both in parallel, as here.
+
+ elfutils is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
/* SH specific relocation handling.
- Copyright (C) 2000, 2001, 2002, 2005 Red Hat, Inc.
+ Copyright (C) 2000-2010 Red Hat, Inc.
- This file is part of Red Hat elfutils.
+ This file is part of elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2000.
- Red Hat elfutils is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by the
- Free Software Foundation; version 2 of the License.
+ This file is free software; you can redistribute it and/or modify
+ it under the terms of either
- Red Hat elfutils is distributed in the hope that it will be useful, but
+ * the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 3 of the License, or (at
+ your option) any later version
+
+ or
+
+ * the GNU General Public License as published by the Free
+ Software Foundation; either version 2 of the License, or (at
+ your option) any later version
+
+ or both in parallel, as here.
+
+ elfutils is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
/* SPARC specific symbolic name handling.
- Copyright (C) 2002, 2003, 2005, 2007, 2008 Red Hat, Inc.
+ Copyright (C) 2002-2010 Red Hat, Inc.
- This file is part of Red Hat elfutils.
+ This file is part of elfutils.
Written by Jakub Jelinek <jakub@redhat.com>, 2002.
- Red Hat elfutils is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by the
- Free Software Foundation; version 2 of the License.
+ This file is free software; you can redistribute it and/or modify
+ it under the terms of either
- Red Hat elfutils is distributed in the hope that it will be useful, but
+ * the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 3 of the License, or (at
+ your option) any later version
+
+ or
+
+ * the GNU General Public License as published by the Free
+ Software Foundation; either version 2 of the License, or (at
+ your option) any later version
+
+ or both in parallel, as here.
+
+ elfutils is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
/* x86_64 specific symbolic name handling.
- Copyright (C) 2002, 2005 Red Hat, Inc.
+ Copyright (C) 2002-2010 Red Hat, Inc.
- This file is part of Red Hat elfutils.
+ This file is part of elfutils.
+ Written by Ulrich Drepper <drepper@redhat.com>, 2002.
- Red Hat elfutils is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by the
- Free Software Foundation; version 2 of the License.
+ This file is free software; you can redistribute it and/or modify
+ it under the terms of either
- Red Hat elfutils is distributed in the hope that it will be useful, but
+ * the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 3 of the License, or (at
+ your option) any later version
+
+ or
+
+ * the GNU General Public License as published by the Free
+ Software Foundation; either version 2 of the License, or (at
+ your option) any later version
+
+ or both in parallel, as here.
+
+ elfutils is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
## Process this file with automake to create Makefile.in
##
-## Copyright (C) 2002-2010 Red Hat, Inc.
+## Copyright (C) 2002-2011 Red Hat, Inc.
- ## This file is part of Red Hat elfutils.
+ ## This file is part of elfutils.
##
- ## Red Hat elfutils is free software; you can redistribute it and/or modify
- ## it under the terms of the GNU General Public License as published by the
- ## Free Software Foundation; version 2 of the License.
+ ## This file is free software; you can redistribute it and/or modify
+ ## it under the terms of either
##
- ## Red Hat elfutils is distributed in the hope that it will be useful, but
+ ## * the GNU Lesser General Public License as published by the Free
+ ## Software Foundation; either version 3 of the License, or (at
+ ## your option) any later version
+ ##
+ ## or
+ ##
+ ## * the GNU General Public License as published by the Free
+ ## Software Foundation; either version 2 of the License, or (at
+ ## your option) any later version
+ ##
+ ## or both in parallel, as here.
+ ##
+ ## elfutils is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
## General Public License for more details.
/* Retrieve ELF descriptor used for DWARF access.
- Copyright (C) 2002, 2003, 2004, 2005, 2009 Red Hat, Inc.
+ Copyright (C) 2002-2010 Red Hat, Inc.
- This file is part of Red Hat elfutils.
+ This file is part of elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
- Red Hat elfutils is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by the
- Free Software Foundation; version 2 of the License.
+ This file is free software; you can redistribute it and/or modify
+ it under the terms of either
- Red Hat elfutils is distributed in the hope that it will be useful, but
+ * the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 3 of the License, or (at
+ your option) any later version
+
+ or
+
+ * the GNU General Public License as published by the Free
+ Software Foundation; either version 2 of the License, or (at
+ your option) any later version
+
+ or both in parallel, as here.
+
+ elfutils is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
--- /dev/null
- This file is part of Red Hat elfutils.
+/* Return relocatable address from attribute.
+ Copyright (C) 2010 Red Hat, Inc.
- Red Hat elfutils is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by the
- Free Software Foundation; version 2 of the License.
+
- Red Hat elfutils is distributed in the hope that it will be useful, but
++ This file is part of elfutils.
+
- You should have received a copy of the GNU General Public License along
- with Red Hat elfutils; if not, write to the Free Software Foundation,
- Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
-
- In addition, as a special exception, Red Hat, Inc. gives You the
- additional right to link the code of Red Hat elfutils with code licensed
- under any Open Source Initiative certified open source license
- (http://www.opensource.org/licenses/index.php) which requires the
- distribution of source code with any binary distribution and to
- distribute linked combinations of the two. Non-GPL Code permitted under
- this exception must only link to the code of Red Hat elfutils through
- those well defined interfaces identified in the file named EXCEPTION
- found in the source code files (the "Approved Interfaces"). The files
- of Non-GPL Code may instantiate templates or use macros or inline
- functions from the Approved Interfaces without causing the resulting
- work to be covered by the GNU General Public License. Only Red Hat,
- Inc. may make changes or additions to the list of Approved Interfaces.
- Red Hat's grant of this exception is conditioned upon your not adding
- any new exceptions. If you wish to add a new Approved Interface or
- exception, please contact Red Hat. You must obey the GNU General Public
- License in all respects for all of the Red Hat elfutils code and other
- code used in conjunction with Red Hat elfutils except the Non-GPL Code
- covered by this exception. If you modify this file, you may extend this
- exception to your version of the file, but you are not obligated to do
- so. If you do not wish to provide this exception without modification,
- you must delete this exception statement from your version and license
- this file solely under the GPL without exception.
-
- Red Hat elfutils is an included package of the Open Invention Network.
- An included package of the Open Invention Network is a package for which
- Open Invention Network licensees cross-license their patents. No patent
- license is granted, either expressly or impliedly, by designation as an
- included package. Should you wish to participate in the Open Invention
- Network licensing program, please visit www.openinventionnetwork.com
- <http://www.openinventionnetwork.com>. */
++ This file is free software; you can redistribute it and/or modify
++ it under the terms of either
++
++ * the GNU Lesser General Public License as published by the Free
++ Software Foundation; either version 3 of the License, or (at
++ your option) any later version
++
++ or
++
++ * the GNU General Public License as published by the Free
++ Software Foundation; either version 2 of the License, or (at
++ your option) any later version
++
++ or both in parallel, as here.
++
++ elfutils is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
++ You should have received copies of the GNU General Public License and
++ the GNU Lesser General Public License along with this program. If
++ not, see <http://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "libdwP.h"
+#include <dwarf.h>
+
+
+int
+dwarf_form_relocatable (attr, reloc)
+ Dwarf_Attribute *attr;
+ Dwarf_Relocatable *reloc;
+{
+ if (attr == NULL)
+ return -1;
+
+ *reloc = (Dwarf_Relocatable)
+ {
+ .sec = cu_sec_idx (attr->cu), .form = attr->form,
+ .cu = attr->cu, .valp = attr->valp,
+ };
+
+ return 0;
+}
+INTDEF (dwarf_form_relocatable)
/* Get CFI from DWARF file.
- Copyright (C) 2009 Red Hat, Inc.
+ Copyright (C) 2009-2010 Red Hat, Inc.
- This file is part of Red Hat elfutils.
+ This file is part of elfutils.
- Red Hat elfutils is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by the
- Free Software Foundation; version 2 of the License.
+ This file is free software; you can redistribute it and/or modify
+ it under the terms of either
- Red Hat elfutils is distributed in the hope that it will be useful, but
+ * the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 3 of the License, or (at
+ your option) any later version
+
+ or
+
+ * the GNU General Public License as published by the Free
+ Software Foundation; either version 2 of the License, or (at
+ your option) any later version
+
+ or both in parallel, as here.
+
+ elfutils is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
--- /dev/null
- This file is part of Red Hat elfutils.
+/* Enumerate the PC ranges covered by a location list.
+ Copyright (C) 2010 Red Hat, Inc.
- Red Hat elfutils is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by the
- Free Software Foundation; version 2 of the License.
+
- Red Hat elfutils is distributed in the hope that it will be useful, but
++ This file is part of elfutils.
+
- You should have received a copy of the GNU General Public License along
- with Red Hat elfutils; if not, write to the Free Software Foundation,
- Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
-
- In addition, as a special exception, Red Hat, Inc. gives You the
- additional right to link the code of Red Hat elfutils with code licensed
- under any Open Source Initiative certified open source license
- (http://www.opensource.org/licenses/index.php) which requires the
- distribution of source code with any binary distribution and to
- distribute linked combinations of the two. Non-GPL Code permitted under
- this exception must only link to the code of Red Hat elfutils through
- those well defined interfaces identified in the file named EXCEPTION
- found in the source code files (the "Approved Interfaces"). The files
- of Non-GPL Code may instantiate templates or use macros or inline
- functions from the Approved Interfaces without causing the resulting
- work to be covered by the GNU General Public License. Only Red Hat,
- Inc. may make changes or additions to the list of Approved Interfaces.
- Red Hat's grant of this exception is conditioned upon your not adding
- any new exceptions. If you wish to add a new Approved Interface or
- exception, please contact Red Hat. You must obey the GNU General Public
- License in all respects for all of the Red Hat elfutils code and other
- code used in conjunction with Red Hat elfutils except the Non-GPL Code
- covered by this exception. If you modify this file, you may extend this
- exception to your version of the file, but you are not obligated to do
- so. If you do not wish to provide this exception without modification,
- you must delete this exception statement from your version and license
- this file solely under the GPL without exception.
-
- Red Hat elfutils is an included package of the Open Invention Network.
- An included package of the Open Invention Network is a package for which
- Open Invention Network licensees cross-license their patents. No patent
- license is granted, either expressly or impliedly, by designation as an
- included package. Should you wish to participate in the Open Invention
- Network licensing program, please visit www.openinventionnetwork.com
- <http://www.openinventionnetwork.com>. */
++ This file is free software; you can redistribute it and/or modify
++ it under the terms of either
++
++ * the GNU Lesser General Public License as published by the Free
++ Software Foundation; either version 3 of the License, or (at
++ your option) any later version
++
++ or
++
++ * the GNU General Public License as published by the Free
++ Software Foundation; either version 2 of the License, or (at
++ your option) any later version
++
++ or both in parallel, as here.
++
++ elfutils is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
++ You should have received copies of the GNU General Public License and
++ the GNU Lesser General Public License along with this program. If
++ not, see <http://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "relocate.h"
+#include <dwarf.h>
+#include <assert.h>
+
+
+ptrdiff_t
+dwarf_getlocation_relocatable (Dwarf_Attribute *attr, ptrdiff_t offset,
+ Dwarf_Relocatable *basep,
+ Dwarf_Relocatable *startp,
+ Dwarf_Relocatable *endp,
+ Dwarf_Op **expr, size_t *exprlen)
+{
+ if (attr == NULL)
+ return -1;
+
+ unsigned int sec_idx = IDX_debug_loc;
+ Dwarf_Block block;
+ if (offset == 0)
+ switch (attr->form)
+ {
+ case DW_FORM_block:
+ case DW_FORM_block1:
+ case DW_FORM_block2:
+ case DW_FORM_block4:
+ if (unlikely (attr->cu->version >= 4))
+ {
+ __libdw_seterrno (DWARF_E_NO_LOCLIST);
+ return -1;
+ }
+
+ case DW_FORM_exprloc:
+ if (unlikely (INTUSE(dwarf_formblock) (attr, &block) < 0))
+ return -1;
+
+ sec_idx = cu_sec_idx (attr->cu);
+ *startp = (Dwarf_Relocatable) { .adjust = 0 };
+ *endp = (Dwarf_Relocatable) { .adjust = (Dwarf_Addr) -1 };
+
+ /* A offset into .debug_loc will never be 1, it must be at least a
+ multiple of 4. So we can return 1 as a special case value to
+ mark there are no ranges to look for on the next call. */
+ offset = 1;
+ break;
+ }
+ else if (offset == 1)
+ return 0;
+
+ if (offset != 1)
+ /* Iterate from last position. */
+ offset = __libdw_ranges_relocatable (attr->cu, attr, offset,
+ basep, startp, endp, &block);
+
+ /* Parse the block into internal form. */
+ if (offset > 0 && expr != NULL
+ && __libdw_getlocation (attr, &block, true, expr, exprlen, sec_idx) < 0)
+ offset = -1;
+
+ return offset;
+}
--- /dev/null
- This file is part of Red Hat elfutils.
+/* Return relocatable address from DW_OP_addr in a DWARF expression.
+ Copyright (C) 2010 Red Hat, Inc.
- Red Hat elfutils is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by the
- Free Software Foundation; version 2 of the License.
+
- Red Hat elfutils is distributed in the hope that it will be useful, but
++ This file is part of elfutils.
+
- You should have received a copy of the GNU General Public License along
- with Red Hat elfutils; if not, write to the Free Software Foundation,
- Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
-
- In addition, as a special exception, Red Hat, Inc. gives You the
- additional right to link the code of Red Hat elfutils with code licensed
- under any Open Source Initiative certified open source license
- (http://www.opensource.org/licenses/index.php) which requires the
- distribution of source code with any binary distribution and to
- distribute linked combinations of the two. Non-GPL Code permitted under
- this exception must only link to the code of Red Hat elfutils through
- those well defined interfaces identified in the file named EXCEPTION
- found in the source code files (the "Approved Interfaces"). The files
- of Non-GPL Code may instantiate templates or use macros or inline
- functions from the Approved Interfaces without causing the resulting
- work to be covered by the GNU General Public License. Only Red Hat,
- Inc. may make changes or additions to the list of Approved Interfaces.
- Red Hat's grant of this exception is conditioned upon your not adding
- any new exceptions. If you wish to add a new Approved Interface or
- exception, please contact Red Hat. You must obey the GNU General Public
- License in all respects for all of the Red Hat elfutils code and other
- code used in conjunction with Red Hat elfutils except the Non-GPL Code
- covered by this exception. If you modify this file, you may extend this
- exception to your version of the file, but you are not obligated to do
- so. If you do not wish to provide this exception without modification,
- you must delete this exception statement from your version and license
- this file solely under the GPL without exception.
-
- Red Hat elfutils is an included package of the Open Invention Network.
- An included package of the Open Invention Network is a package for which
- Open Invention Network licensees cross-license their patents. No patent
- license is granted, either expressly or impliedly, by designation as an
- included package. Should you wish to participate in the Open Invention
- Network licensing program, please visit www.openinventionnetwork.com
- <http://www.openinventionnetwork.com>. */
++ This file is free software; you can redistribute it and/or modify
++ it under the terms of either
++
++ * the GNU Lesser General Public License as published by the Free
++ Software Foundation; either version 3 of the License, or (at
++ your option) any later version
++
++ or
++
++ * the GNU General Public License as published by the Free
++ Software Foundation; either version 2 of the License, or (at
++ your option) any later version
++
++ or both in parallel, as here.
++
++ elfutils is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
++ You should have received copies of the GNU General Public License and
++ the GNU Lesser General Public License along with this program. If
++ not, see <http://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "libdwP.h"
+#include <dwarf.h>
+
+int
+dwarf_getlocation_relocatable_addr (attr, op, reloc)
+ Dwarf_Attribute *attr;
+ const Dwarf_Op *op;
+ Dwarf_Relocatable *reloc;
+{
+ if (attr == NULL)
+ return -1;
+
+ if (unlikely (op->atom != DW_OP_addr))
+ {
+ __libdw_seterrno (DWARF_E_INVALID_ACCESS);
+ return -1;
+ }
+
+ *reloc = (Dwarf_Relocatable)
+ {
+ .form = DW_FORM_addr,
+ .cu = attr->cu,
+ .adjust = op->number,
+ .symndx = op->number2,
+ };
+
+ if (reloc->symndx != 0)
+ /* Setting .valp non-null with .symndx nonzero indicates that
+ the adjustment is relative to a known symndx, but not resolved
+ to section-relative. */
+ reloc->valp = (void *) -1l;
+
+ /* If the attribute this expression came from was a location list, then
+ the relevant symtab is that of the .rela.debug_loc section; otherwise
+ it's that of the section where the attribute resides. */
+
+ switch (attr->form)
+ {
+ case DW_FORM_data4:
+ case DW_FORM_data8:
+ case DW_FORM_sec_offset:
+ reloc->sec = IDX_debug_loc;
+ break;
+
+ default:
+ reloc->sec = cu_sec_idx (reloc->cu);
+ break;
+ }
+
+ return 0;
+}
/* Find line information for address.
- Copyright (C) 2004, 2005 Red Hat, Inc.
+ Copyright (C) 2004-2010 Red Hat, Inc.
- This file is part of Red Hat elfutils.
+ This file is part of elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2004.
- Red Hat elfutils is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by the
- Free Software Foundation; version 2 of the License.
+ This file is free software; you can redistribute it and/or modify
+ it under the terms of either
- Red Hat elfutils is distributed in the hope that it will be useful, but
+ * the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 3 of the License, or (at
+ your option) any later version
+
+ or
+
+ * the GNU General Public License as published by the Free
+ Software Foundation; either version 2 of the License, or (at
+ your option) any later version
+
+ or both in parallel, as here.
+
+ elfutils is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
/* Find line information for given file/line/column triple.
- Copyright (C) 2005-2009 Red Hat, Inc.
+ Copyright (C) 2005-2010 Red Hat, Inc.
- This file is part of Red Hat elfutils.
+ This file is part of elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2005.
- Red Hat elfutils is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by the
- Free Software Foundation; version 2 of the License.
+ This file is free software; you can redistribute it and/or modify
+ it under the terms of either
- Red Hat elfutils is distributed in the hope that it will be useful, but
+ * the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 3 of the License, or (at
+ your option) any later version
+
+ or
+
+ * the GNU General Public License as published by the Free
+ Software Foundation; either version 2 of the License, or (at
+ your option) any later version
+
+ or both in parallel, as here.
+
+ elfutils is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
--- /dev/null
- This file is part of Red Hat elfutils.
+/* Find line information for relocatable address.
+ Copyright (C) 2010 Red Hat, Inc.
- Red Hat elfutils is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by the
- Free Software Foundation; version 2 of the License.
+
- Red Hat elfutils is distributed in the hope that it will be useful, but
++ This file is part of elfutils.
+
- You should have received a copy of the GNU General Public License along
- with Red Hat elfutils; if not, write to the Free Software Foundation,
- Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
-
- In addition, as a special exception, Red Hat, Inc. gives You the
- additional right to link the code of Red Hat elfutils with code licensed
- under any Open Source Initiative certified open source license
- (http://www.opensource.org/licenses/index.php) which requires the
- distribution of source code with any binary distribution and to
- distribute linked combinations of the two. Non-GPL Code permitted under
- this exception must only link to the code of Red Hat elfutils through
- those well defined interfaces identified in the file named EXCEPTION
- found in the source code files (the "Approved Interfaces"). The files
- of Non-GPL Code may instantiate templates or use macros or inline
- functions from the Approved Interfaces without causing the resulting
- work to be covered by the GNU General Public License. Only Red Hat,
- Inc. may make changes or additions to the list of Approved Interfaces.
- Red Hat's grant of this exception is conditioned upon your not adding
- any new exceptions. If you wish to add a new Approved Interface or
- exception, please contact Red Hat. You must obey the GNU General Public
- License in all respects for all of the Red Hat elfutils code and other
- code used in conjunction with Red Hat elfutils except the Non-GPL Code
- covered by this exception. If you modify this file, you may extend this
- exception to your version of the file, but you are not obligated to do
- so. If you do not wish to provide this exception without modification,
- you must delete this exception statement from your version and license
- this file solely under the GPL without exception.
-
- Red Hat elfutils is an included package of the Open Invention Network.
- An included package of the Open Invention Network is a package for which
- Open Invention Network licensees cross-license their patents. No patent
- license is granted, either expressly or impliedly, by designation as an
- included package. Should you wish to participate in the Open Invention
- Network licensing program, please visit www.openinventionnetwork.com
- <http://www.openinventionnetwork.com>. */
++ This file is free software; you can redistribute it and/or modify
++ it under the terms of either
++
++ * the GNU Lesser General Public License as published by the Free
++ Software Foundation; either version 3 of the License, or (at
++ your option) any later version
++
++ or
++
++ * the GNU General Public License as published by the Free
++ Software Foundation; either version 2 of the License, or (at
++ your option) any later version
++
++ or both in parallel, as here.
++
++ elfutils is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
++ You should have received copies of the GNU General Public License and
++ the GNU Lesser General Public License along with this program. If
++ not, see <http://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "relocate.h"
+#include <assert.h>
+
+
+Dwarf_Line *
+dwarf_getsrc_relocatable (Dwarf_Die *cudie, Dwarf_Relocatable *reloc)
+{
+ Dwarf_Lines *lines;
+ size_t nlines;
+
+ if (INTUSE(dwarf_getsrclines) (cudie, &lines, &nlines) != 0)
+ return NULL;
+
+ /* First we can partially resolve the relocatable address to
+ a symndx and a section-relative offset. */
+ GElf_Sym sym;
+ GElf_Word shndx;
+ if (reloc->valp != NULL)
+ {
+ int result = INTUSE(dwarf_relocatable_info) (reloc,
+ NULL, NULL, NULL, NULL);
+ if (unlikely (result < 0))
+ return NULL;
+ assert (reloc->valp == NULL);
+ shndx = result;
+ }
+ else if (reloc->symndx == STN_UNDEF)
+ shndx = 0;
+ else
+ {
+ /* The relocation is already resolved to a symndx and
+ section-relative address, but we have to recover that shndx. */
+ struct dwarf_section_reloc *const r
+ = reloc->cu->dbg->relocate->sectionrel[reloc->sec];
+ if (unlikely (gelf_getsymshndx (r->symdata, r->symxndxdata,
+ reloc->symndx, &sym, &shndx) == NULL))
+ {
+ __libdw_seterrno (DWARF_E_RELBADSYM);
+ return NULL;
+ }
+ if (sym.st_shndx == SHN_ABS)
+ shndx = 0;
+ else if (likely (sym.st_shndx < SHN_LORESERVE)
+ && likely (sym.st_shndx != SHN_UNDEF))
+ shndx = sym.st_shndx;
+ else if (sym.st_shndx != SHN_XINDEX)
+ {
+ __libdw_seterrno (DWARF_E_RELUNDEF);
+ return NULL;
+ }
+ }
+
+ if (lines->reloc == NULL)
+ {
+ if (shndx == 0)
+ return INTUSE(dwarf_getsrc_die) (cudie, reloc->adjust);
+ else
+ goto nomatch;
+ }
+
+ /* The lines are sorted by address, so we can use binary search. */
+ const Dwarf_Addr addr = reloc->adjust;
+ size_t l = 0, u = nlines;
+ while (l < u)
+ {
+ size_t idx = (l + u) / 2;
+ const GElf_Word this_shndx = lines->reloc[idx * 2 + 1];
+ if (shndx < this_shndx)
+ u = idx;
+ else if (shndx > this_shndx)
+ l = idx + 1;
+ else if (addr < lines->info[idx].addr)
+ u = idx;
+ else if (addr > lines->info[idx].addr || lines->info[idx].end_sequence)
+ l = idx + 1;
+ else
+ return &lines->info[idx];
+ }
+
+ if (nlines > 0)
+ assert (lines->info[nlines - 1].end_sequence);
+
+ /* If none were equal, the closest one below is what we want. We
+ never want the last one, because it's the end-sequence marker
+ with an address at the high bound of the CU's code. If the debug
+ information is faulty and no end-sequence marker is present, we
+ still ignore it. */
+ if (u > 0 && u < nlines && addr > lines->info[u - 1].addr)
+ {
+ while (lines->info[u - 1].end_sequence && u > 0)
+ --u;
+ if (u > 0)
+ return &lines->info[u - 1];
+ }
+
+ nomatch:
+ __libdw_seterrno (DWARF_E_ADDR_OUTOFRANGE);
+ return NULL;
+}
--- /dev/null
- This file is part of Red Hat elfutils.
+/* Determine whether a DIE covers a PC address.
+ Copyright (C) 2010 Red Hat, Inc.
- Red Hat elfutils is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by the
- Free Software Foundation; version 2 of the License.
+
- Red Hat elfutils is distributed in the hope that it will be useful, but
++ This file is part of elfutils.
+
- You should have received a copy of the GNU General Public License along
- with Red Hat elfutils; if not, write to the Free Software Foundation,
- Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
-
- In addition, as a special exception, Red Hat, Inc. gives You the
- additional right to link the code of Red Hat elfutils with code licensed
- under any Open Source Initiative certified open source license
- (http://www.opensource.org/licenses/index.php) which requires the
- distribution of source code with any binary distribution and to
- distribute linked combinations of the two. Non-GPL Code permitted under
- this exception must only link to the code of Red Hat elfutils through
- those well defined interfaces identified in the file named EXCEPTION
- found in the source code files (the "Approved Interfaces"). The files
- of Non-GPL Code may instantiate templates or use macros or inline
- functions from the Approved Interfaces without causing the resulting
- work to be covered by the GNU General Public License. Only Red Hat,
- Inc. may make changes or additions to the list of Approved Interfaces.
- Red Hat's grant of this exception is conditioned upon your not adding
- any new exceptions. If you wish to add a new Approved Interface or
- exception, please contact Red Hat. You must obey the GNU General Public
- License in all respects for all of the Red Hat elfutils code and other
- code used in conjunction with Red Hat elfutils except the Non-GPL Code
- covered by this exception. If you modify this file, you may extend this
- exception to your version of the file, but you are not obligated to do
- so. If you do not wish to provide this exception without modification,
- you must delete this exception statement from your version and license
- this file solely under the GPL without exception.
-
- Red Hat elfutils is an included package of the Open Invention Network.
- An included package of the Open Invention Network is a package for which
- Open Invention Network licensees cross-license their patents. No patent
- license is granted, either expressly or impliedly, by designation as an
- included package. Should you wish to participate in the Open Invention
- Network licensing program, please visit www.openinventionnetwork.com
- <http://www.openinventionnetwork.com>. */
++ This file is free software; you can redistribute it and/or modify
++ it under the terms of either
++
++ * the GNU Lesser General Public License as published by the Free
++ Software Foundation; either version 3 of the License, or (at
++ your option) any later version
++
++ or
++
++ * the GNU General Public License as published by the Free
++ Software Foundation; either version 2 of the License, or (at
++ your option) any later version
++
++ or both in parallel, as here.
++
++ elfutils is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
++ You should have received copies of the GNU General Public License and
++ the GNU Lesser General Public License along with this program. If
++ not, see <http://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "libdwP.h"
+#include <dwarf.h>
+
+
+int
+dwarf_haspc_relocatable (Dwarf_Die *die, Dwarf_Relocatable *pc)
+{
+ if (die == NULL)
+ return -1;
+
+ GElf_Sym pc_sym;
+ GElf_Sxword pc_addend;
+ int pc_shndx = INTUSE(dwarf_relocatable_info) (pc, &pc_sym, NULL,
+ &pc_addend, NULL);
+ if (pc_shndx < 0)
+ return pc_shndx;
+ pc_sym.st_value += pc_addend;
+
+ Dwarf_Relocatable base;
+ Dwarf_Relocatable begin;
+ Dwarf_Relocatable end;
+ ptrdiff_t offset = 0;
+ while ((offset = INTUSE(dwarf_ranges_relocatable) (die, offset, &base,
+ &begin, &end)) > 0)
+ if (begin.valp == NULL && end.valp == NULL && pc->valp == NULL)
+ {
+ if (pc->adjust >= begin.adjust && pc->adjust < end.adjust)
+ return 1;
+ }
+ else
+ {
+ /* A relocatable address matches if it's in the same section
+ and the section-relative offsets match. */
+
+ GElf_Sym sym;
+ GElf_Sxword addend;
+ int shndx = INTUSE(dwarf_relocatable_info) (&begin, &sym, NULL,
+ &addend, NULL);
+ if (shndx < 0)
+ return -1;
+ if (shndx == pc_shndx && sym.st_shndx == pc_sym.st_shndx
+ && pc_sym.st_value >= sym.st_value + addend)
+ {
+ if (pc_sym.st_value == sym.st_value + addend)
+ return 1;
+ shndx = INTUSE(dwarf_relocatable_info) (&end, &sym, NULL,
+ &addend, NULL);
+ if (shndx < 0)
+ return -1;
+ if (shndx == pc_shndx && sym.st_shndx == pc_sym.st_shndx
+ && pc_sym.st_value < sym.st_value + addend)
+ return 1;
+ }
+ }
+
+ return offset;
+}
+INTDEF (dwarf_haspc_relocatable)
--- /dev/null
- Red Hat elfutils is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by the
- Free Software Foundation; version 2 of the License.
+/* Return relocatable line address.
+ Copyright (C) 2010 Red Hat, Inc.
+ Written by Ulrich Drepper <drepper@redhat.com>, 2004.
+
- Red Hat elfutils is distributed in the hope that it will be useful, but
++ This file is part of elfutils.
+
- You should have received a copy of the GNU General Public License along
- with Red Hat elfutils; if not, write to the Free Software Foundation,
- Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
-
- In addition, as a special exception, Red Hat, Inc. gives You the
- additional right to link the code of Red Hat elfutils with code licensed
- under any Open Source Initiative certified open source license
- (http://www.opensource.org/licenses/index.php) which requires the
- distribution of source code with any binary distribution and to
- distribute linked combinations of the two. Non-GPL Code permitted under
- this exception must only link to the code of Red Hat elfutils through
- those well defined interfaces identified in the file named EXCEPTION
- found in the source code files (the "Approved Interfaces"). The files
- of Non-GPL Code may instantiate templates or use macros or inline
- functions from the Approved Interfaces without causing the resulting
- work to be covered by the GNU General Public License. Only Red Hat,
- Inc. may make changes or additions to the list of Approved Interfaces.
- Red Hat's grant of this exception is conditioned upon your not adding
- any new exceptions. If you wish to add a new Approved Interface or
- exception, please contact Red Hat. You must obey the GNU General Public
- License in all respects for all of the Red Hat elfutils code and other
- code used in conjunction with Red Hat elfutils except the Non-GPL Code
- covered by this exception. If you modify this file, you may extend this
- exception to your version of the file, but you are not obligated to do
- so. If you do not wish to provide this exception without modification,
- you must delete this exception statement from your version and license
- this file solely under the GPL without exception.
-
- Red Hat elfutils is an included package of the Open Invention Network.
- An included package of the Open Invention Network is a package for which
- Open Invention Network licensees cross-license their patents. No patent
- license is granted, either expressly or impliedly, by designation as an
- included package. Should you wish to participate in the Open Invention
- Network licensing program, please visit www.openinventionnetwork.com
- <http://www.openinventionnetwork.com>. */
++ This file is free software; you can redistribute it and/or modify
++ it under the terms of either
++
++ * the GNU Lesser General Public License as published by the Free
++ Software Foundation; either version 3 of the License, or (at
++ your option) any later version
++
++ or
++
++ * the GNU General Public License as published by the Free
++ Software Foundation; either version 2 of the License, or (at
++ your option) any later version
++
++ or both in parallel, as here.
++
++ elfutils is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
++ You should have received copies of the GNU General Public License and
++ the GNU Lesser General Public License along with this program. If
++ not, see <http://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "libdwP.h"
+#include <dwarf.h>
+
+
+int
+dwarf_line_relocatable (line, reloc)
+ Dwarf_Line *line;
+ Dwarf_Relocatable *reloc;
+{
+ if (line == NULL)
+ return -1;
+
+ const int *const linerel = line->cu->lines->reloc;
+ const size_t idx = line - line->cu->lines->info;
+
+ *reloc = (Dwarf_Relocatable)
+ {
+ .sec = IDX_debug_line, .form = DW_FORM_addr,
+ .cu = line->cu,
+ .symndx = linerel == NULL ? STN_UNDEF : linerel[idx * 2],
+ .adjust = line->addr
+ };
+
+ return 0;
+}
/* Return line address.
- Copyright (C) 2004 Red Hat, Inc.
+ Copyright (C) 2004-2010 Red Hat, Inc.
- This file is part of Red Hat elfutils.
+ This file is part of elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2004.
- Red Hat elfutils is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by the
- Free Software Foundation; version 2 of the License.
+ This file is free software; you can redistribute it and/or modify
+ it under the terms of either
- Red Hat elfutils is distributed in the hope that it will be useful, but
+ * the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 3 of the License, or (at
+ your option) any later version
+
+ or
+
+ * the GNU General Public License as published by the Free
+ Software Foundation; either version 2 of the License, or (at
+ your option) any later version
+
+ or both in parallel, as here.
+
+ elfutils is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
/* Find line information for address.
- Copyright (C) 2004 Red Hat, Inc.
+ Copyright (C) 2004-2010 Red Hat, Inc.
- This file is part of Red Hat elfutils.
+ This file is part of elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2004.
- Red Hat elfutils is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by the
- Free Software Foundation; version 2 of the License.
+ This file is free software; you can redistribute it and/or modify
+ it under the terms of either
- Red Hat elfutils is distributed in the hope that it will be useful, but
+ * the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 3 of the License, or (at
+ your option) any later version
+
+ or
+
+ * the GNU General Public License as published by the Free
+ Software Foundation; either version 2 of the License, or (at
+ your option) any later version
+
+ or both in parallel, as here.
+
+ elfutils is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
--- /dev/null
- This file is part of Red Hat elfutils.
+/* Enumerate the PC ranges covered by a DIE.
+ Copyright (C) 2010 Red Hat, Inc.
- Red Hat elfutils is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by the
- Free Software Foundation; version 2 of the License.
+
- Red Hat elfutils is distributed in the hope that it will be useful, but
++ This file is part of elfutils.
+
- You should have received a copy of the GNU General Public License along
- with Red Hat elfutils; if not, write to the Free Software Foundation,
- Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
-
- In addition, as a special exception, Red Hat, Inc. gives You the
- additional right to link the code of Red Hat elfutils with code licensed
- under any Open Source Initiative certified open source license
- (http://www.opensource.org/licenses/index.php) which requires the
- distribution of source code with any binary distribution and to
- distribute linked combinations of the two. Non-GPL Code permitted under
- this exception must only link to the code of Red Hat elfutils through
- those well defined interfaces identified in the file named EXCEPTION
- found in the source code files (the "Approved Interfaces"). The files
- of Non-GPL Code may instantiate templates or use macros or inline
- functions from the Approved Interfaces without causing the resulting
- work to be covered by the GNU General Public License. Only Red Hat,
- Inc. may make changes or additions to the list of Approved Interfaces.
- Red Hat's grant of this exception is conditioned upon your not adding
- any new exceptions. If you wish to add a new Approved Interface or
- exception, please contact Red Hat. You must obey the GNU General Public
- License in all respects for all of the Red Hat elfutils code and other
- code used in conjunction with Red Hat elfutils except the Non-GPL Code
- covered by this exception. If you modify this file, you may extend this
- exception to your version of the file, but you are not obligated to do
- so. If you do not wish to provide this exception without modification,
- you must delete this exception statement from your version and license
- this file solely under the GPL without exception.
-
- Red Hat elfutils is an included package of the Open Invention Network.
- An included package of the Open Invention Network is a package for which
- Open Invention Network licensees cross-license their patents. No patent
- license is granted, either expressly or impliedly, by designation as an
- included package. Should you wish to participate in the Open Invention
- Network licensing program, please visit www.openinventionnetwork.com
- <http://www.openinventionnetwork.com>. */
++ This file is free software; you can redistribute it and/or modify
++ it under the terms of either
++
++ * the GNU Lesser General Public License as published by the Free
++ Software Foundation; either version 3 of the License, or (at
++ your option) any later version
++
++ or
++
++ * the GNU General Public License as published by the Free
++ Software Foundation; either version 2 of the License, or (at
++ your option) any later version
++
++ or both in parallel, as here.
++
++ elfutils is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
++ You should have received copies of the GNU General Public License and
++ the GNU Lesser General Public License along with this program. If
++ not, see <http://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "relocate.h"
+#include <dwarf.h>
+#include <assert.h>
+
+ptrdiff_t
+internal_function
+__libdw_ranges_relocatable (struct Dwarf_CU *cu, Dwarf_Attribute *attr,
+ ptrdiff_t offset,
+ Dwarf_Relocatable *basep,
+ Dwarf_Relocatable *startp, Dwarf_Relocatable *endp,
+ Dwarf_Block *exprloc)
+{
+ if (offset == 1)
+ return 0;
+
+ const unsigned int sec_idx = (exprloc != NULL ? IDX_debug_loc
+ : IDX_debug_ranges);
+ unsigned char *readp;
+ unsigned char *readendp;
+ if (offset == 0)
+ {
+ Dwarf_Word start_offset;
+ if ((readp = __libdw_formptr (attr, sec_idx,
+ exprloc != NULL ? DWARF_E_NO_LOCLIST
+ : DWARF_E_NO_DEBUG_RANGES,
+ &readendp, &start_offset)) == NULL)
+ return -1;
+
+ offset = start_offset;
+ assert ((Dwarf_Word) offset == start_offset);
+
+ /* This is a marker that we need to fetch the CU base address. */
+ basep->cu = NULL;
+ }
+ else if (__libdw_offset_in_section (cu->dbg,
+ exprloc != NULL ? IDX_debug_loc
+ : IDX_debug_ranges,
+ offset, 1))
+ return -1l;
+ else
+ {
+ const Elf_Data *d = cu->dbg->sectiondata[sec_idx];
+ readp = d->d_buf + offset;
+ readendp = d->d_buf + d->d_size;
+ }
+
+ inline void store (Dwarf_Relocatable *relocp, ptrdiff_t read_adjust)
+ {
+ *relocp = (Dwarf_Relocatable)
+ {
+ .cu = cu, .sec = sec_idx, .form = DW_FORM_addr,
+ .valp = readp
+ };
+ readp += read_adjust;
+ }
+
+ inline bool finalize_reloc (Dwarf_Relocatable *reloc, unsigned int width)
+ {
+ if (basep->cu == NULL)
+ {
+ /* This is the initial default base address and we have not used it
+ yet. Find the base address of the compilation unit. It will
+ normally be specified by DW_AT_low_pc. In DWARF-3 draft 4, the
+ base address could be overridden by DW_AT_entry_pc. It's been
+ removed, but GCC emits DW_AT_entry_pc and not DW_AT_lowpc for
+ compilation units with discontinuous ranges. */
+
+ Dwarf_Die cudie = CUDIE (cu);
+ Dwarf_Attribute loattr;
+ if (unlikely (INTUSE(dwarf_form_relocatable)
+ (INTUSE(dwarf_attr) (&cudie, DW_AT_low_pc, &loattr)
+ ?: INTUSE(dwarf_attr) (&cudie, DW_AT_entry_pc, &loattr),
+ basep) < 0))
+ return true;
+ }
+
+ GElf_Sxword addend;
+ if (__libdw_relocatable (cu->dbg, sec_idx, reloc->valp, width,
+ NULL, &addend) > 0)
+ {
+ /* The address itself has a relocation.
+ The base address entry must not also have a relocation. */
+
+ if (unlikely (__libdw_relocatable (cu->dbg, sec_idx, basep->valp, width,
+ NULL, &addend) > 0))
+ {
+ __libdw_seterrno (DWARF_E_INVALID_DWARF);
+ return true;
+ }
+ }
+ else
+ /* The address is relative to the base address relocation. */
+ reloc->valp = basep->valp;
+
+ reloc->adjust = addend;
+
+ return false;
+ }
+
+ inline ptrdiff_t finalize (unsigned int width)
+ {
+ if (finalize_reloc (startp, width) || finalize_reloc (endp, width))
+ return -1;
+ return readp - (unsigned char *) cu->dbg->sectiondata[sec_idx]->d_buf;
+ }
+
+#define READ_RANGES(AS, Addr, READ) \
+ while (likely (readendp - readp >= 2 * AS)) \
+ { \
+ Addr begin = READ (readp); \
+ \
+ if (begin == (Addr) -1) \
+ { \
+ /* If this is unrelocated, this is a base address entry. */ \
+ int result = __libdw_relocatable (cu->dbg, sec_idx, readp, AS, \
+ NULL, NULL); \
+ if (unlikely (result < 0)) /* Indigestion. */ \
+ return -1; \
+ if (result == 0) /* Not relocatable. */ \
+ { \
+ readp += AS; \
+ store (basep, AS); \
+ continue; \
+ } \
+ } \
+ else if (begin == 0 && READ (readp + AS) == 0) \
+ { \
+ /* If these are both unrelocated, this is the end of list entry. */\
+ int result = __libdw_relocatable (cu->dbg, sec_idx, readp, AS, \
+ NULL, NULL); \
+ if (result == 0) /* Not relocatable. */ \
+ result = __libdw_relocatable (cu->dbg, sec_idx, readp + AS, AS, \
+ NULL, NULL); \
+ if (unlikely (result < 0)) /* Indigestion. */ \
+ return -1; \
+ if (result == 0) /* Not relocatable: end of list entry. */ \
+ return 0; \
+ } \
+ \
+ /* This is a pair of addresses. */ \
+ store (startp, AS); \
+ store (endp, AS); \
+ \
+ if (exprloc != NULL) \
+ { \
+ if (unlikely (readendp - readp < 2)) \
+ break; \
+ exprloc->length = read_2ubyte_unaligned_inc (cu->dbg, readp); \
+ if (unlikely ((size_t) (readendp - readp) < exprloc->length)) \
+ break; \
+ exprloc->data = readp; \
+ } \
+ \
+ return finalize (AS); \
+ }
+
+ if (cu->address_size == 8)
+ READ_RANGES (8, Elf64_Addr, read_8ubyte_unaligned_noncvt)
+ else
+ READ_RANGES (4, Elf32_Addr, read_4ubyte_unaligned_noncvt)
+
+ __libdw_seterrno (DWARF_E_INVALID_DWARF);
+ return -1;
+}
+
+ptrdiff_t
+dwarf_ranges_relocatable (Dwarf_Die *die, ptrdiff_t offset,
+ Dwarf_Relocatable *basep,
+ Dwarf_Relocatable *startp, Dwarf_Relocatable *endp)
+{
+ if (die == NULL)
+ return -1;
+
+ if (offset != 0)
+ /* Iterate from last position. */
+ return __libdw_ranges_relocatable (die->cu, NULL, offset,
+ basep, startp, endp, NULL);
+
+ Dwarf_Attribute attr_mem;
+
+ /* Usually there is a single contiguous range. */
+ if (INTUSE(dwarf_form_relocatable) (INTUSE(dwarf_attr) (die,
+ DW_AT_high_pc,
+ &attr_mem),
+ endp) == 0
+ && INTUSE(dwarf_form_relocatable) (INTUSE(dwarf_attr) (die,
+ DW_AT_low_pc,
+ &attr_mem),
+ startp) == 0)
+ /* A offset into .debug_ranges will never be 1, it must be at least a
+ multiple of 4. So we can return 1 as a special case value to mark
+ there are no ranges to look for on the next call. */
+ return 1;
+
+ Dwarf_Attribute *attr = INTUSE(dwarf_attr) (die, DW_AT_ranges, &attr_mem);
+ if (attr == NULL)
+ /* No PC attributes in this DIE at all, so an empty range list. */
+ return 0;
+
+ return __libdw_ranges_relocatable (die->cu, attr, 0,
+ basep, startp, endp, NULL);
+}
+INTDEF (dwarf_ranges_relocatable)
--- /dev/null
- This file is part of Red Hat elfutils.
+/* Return relocatable address from attribute.
+ Copyright (C) 2010 Red Hat, Inc.
- Red Hat elfutils is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by the
- Free Software Foundation; version 2 of the License.
+
- Red Hat elfutils is distributed in the hope that it will be useful, but
++ This file is part of elfutils.
+
- You should have received a copy of the GNU General Public License along
- with Red Hat elfutils; if not, write to the Free Software Foundation,
- Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
-
- In addition, as a special exception, Red Hat, Inc. gives You the
- additional right to link the code of Red Hat elfutils with code licensed
- under any Open Source Initiative certified open source license
- (http://www.opensource.org/licenses/index.php) which requires the
- distribution of source code with any binary distribution and to
- distribute linked combinations of the two. Non-GPL Code permitted under
- this exception must only link to the code of Red Hat elfutils through
- those well defined interfaces identified in the file named EXCEPTION
- found in the source code files (the "Approved Interfaces"). The files
- of Non-GPL Code may instantiate templates or use macros or inline
- functions from the Approved Interfaces without causing the resulting
- work to be covered by the GNU General Public License. Only Red Hat,
- Inc. may make changes or additions to the list of Approved Interfaces.
- Red Hat's grant of this exception is conditioned upon your not adding
- any new exceptions. If you wish to add a new Approved Interface or
- exception, please contact Red Hat. You must obey the GNU General Public
- License in all respects for all of the Red Hat elfutils code and other
- code used in conjunction with Red Hat elfutils except the Non-GPL Code
- covered by this exception. If you modify this file, you may extend this
- exception to your version of the file, but you are not obligated to do
- so. If you do not wish to provide this exception without modification,
- you must delete this exception statement from your version and license
- this file solely under the GPL without exception.
-
- Red Hat elfutils is an included package of the Open Invention Network.
- An included package of the Open Invention Network is a package for which
- Open Invention Network licensees cross-license their patents. No patent
- license is granted, either expressly or impliedly, by designation as an
- included package. Should you wish to participate in the Open Invention
- Network licensing program, please visit www.openinventionnetwork.com
- <http://www.openinventionnetwork.com>. */
++ This file is free software; you can redistribute it and/or modify
++ it under the terms of either
++
++ * the GNU Lesser General Public License as published by the Free
++ Software Foundation; either version 3 of the License, or (at
++ your option) any later version
++
++ or
++
++ * the GNU General Public License as published by the Free
++ Software Foundation; either version 2 of the License, or (at
++ your option) any later version
++
++ or both in parallel, as here.
++
++ elfutils is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
++ You should have received copies of the GNU General Public License and
++ the GNU Lesser General Public License along with this program. If
++ not, see <http://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "relocate.h"
+#include <dwarf.h>
+
+
+int
+dwarf_relocatable_info (reloc, sym, name, addend, secname)
+ Dwarf_Relocatable *reloc;
+ GElf_Sym *sym;
+ const char **name;
+ GElf_Sxword *addend;
+ const char **secname;
+{
+ if (reloc == NULL)
+ return -1;
+
+ int width;
+ switch (reloc->form)
+ {
+ default:
+ /* This can't be relocatable. */
+ if (addend != NULL)
+ {
+ if (reloc->valp == NULL)
+ *addend = 0;
+ else
+ {
+ Dwarf_Attribute attr =
+ {
+ .cu = reloc->cu,
+ .form = reloc->form,
+ .valp = (unsigned char *) reloc->valp
+ };
+ if (INTUSE(dwarf_formsdata) (&attr, addend))
+ return -1;
+ }
+ }
+ noreloc:
+ if (addend != NULL)
+ *addend += reloc->adjust;
+ if (sym != NULL)
+ *sym = (GElf_Sym) { .st_shndx = SHN_ABS };
+ if (name != NULL)
+ *name = NULL;
+ if (secname != NULL)
+ *secname = NULL;
+ return 0;
+
+ case DW_FORM_addr:
+ width = reloc->cu->address_size;
+ break;
+
+ case DW_FORM_data4:
+ width = 4;
+ break;
+
+ case DW_FORM_data8:
+ width = 8;
+ break;
+ }
+
+ GElf_Sxword adjust = 0;
+ if (reloc->valp != NULL && reloc->symndx == STN_UNDEF)
+ {
+ int result = __libdw_relocatable (reloc->cu->dbg, reloc->sec,
+ reloc->valp, width,
+ &reloc->symndx, &adjust);
+ if (unlikely (result < 0))
+ return result;
+ if (result == 0)
+ {
+ reloc->valp = NULL;
+ reloc->adjust += adjust;
+ goto noreloc;
+ }
+ }
+
+ struct dwarf_section_reloc *const r
+ = reloc->cu->dbg->relocate->sectionrel[reloc->sec];
+ GElf_Sym sym_mem;
+ GElf_Word shndx;
+ if (sym == NULL)
+ sym = &sym_mem;
+
+ if (unlikely (gelf_getsymshndx (r->symdata, r->symxndxdata,
+ reloc->symndx, sym, &shndx) == NULL))
+ {
+ __libdw_seterrno (DWARF_E_RELBADSYM);
+ return -1;
+ }
+
+ if (reloc->valp != NULL)
+ {
+ /* Turn the adjustment into a section-relative address. */
+ reloc->valp = NULL;
+ reloc->adjust += sym->st_value + adjust;
+ }
+
+ if (name != NULL)
+ {
+ if (sym->st_name == 0)
+ *name = NULL;
+ else if (unlikely (sym->st_name >= r->symstrdata->d_size))
+ {
+ __libdw_seterrno (DWARF_E_RELBADSYM);
+ return -1;
+ }
+ else
+ *name = (const char *) r->symstrdata->d_buf + sym->st_name;
+ }
+
+ if (addend != NULL)
+ /* The adjustment is already section-relative, so we have to
+ remove the st_value portion of it. */
+ *addend = reloc->adjust - sym->st_value;
+
+ int result = (sym->st_shndx < SHN_LORESERVE ? sym->st_shndx
+ : sym->st_shndx == SHN_XINDEX ? shndx : SHN_UNDEF);
+
+ if (secname != NULL)
+ {
+ Elf *symelf = ((Elf_Data_Scn *) r->symdata)->s->elf;
+ size_t shstrndx;
+ GElf_Shdr shdr;
+ if (result == 0
+ || elf_getshdrstrndx (symelf, &shstrndx) < 0
+ || gelf_getshdr (elf_getscn (symelf, result), &shdr) == NULL)
+ *secname = NULL;
+ else
+ *secname = elf_strptr (symelf, shstrndx, shdr.sh_name);
+ }
+
+ return result;
+}
+INTDEF (dwarf_relocatable_info)
/* Interfaces for libdw.
- Copyright (C) 2002-2010 Red Hat, Inc.
+ Copyright (C) 2002-2011 Red Hat, Inc.
- This file is part of Red Hat elfutils.
+ This file is part of elfutils.
- Red Hat elfutils is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by the
- Free Software Foundation; version 2 of the License.
+ This file is free software; you can redistribute it and/or modify
+ it under the terms of either
- Red Hat elfutils is distributed in the hope that it will be useful, but
+ * the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 3 of the License, or (at
+ your option) any later version
+
+ or
+
+ * the GNU General Public License as published by the Free
+ Software Foundation; either version 2 of the License, or (at
+ your option) any later version
+
+ or both in parallel, as here.
+
+ elfutils is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
/* Internal definitions for libdwarf.
- Copyright (C) 2002-2011 Red Hat, Inc.
+ Copyright (C) 2002-2012 Red Hat, Inc.
- This file is part of Red Hat elfutils.
+ This file is part of elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
- Red Hat elfutils is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by the
- Free Software Foundation; version 2 of the License.
+ This file is free software; you can redistribute it and/or modify
+ it under the terms of either
- Red Hat elfutils is distributed in the hope that it will be useful, but
+ * the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 3 of the License, or (at
+ your option) any later version
+
+ or
+
+ * the GNU General Public License as published by the Free
+ Software Foundation; either version 2 of the License, or (at
+ your option) any later version
+
+ or both in parallel, as here.
+
+ elfutils is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
--- /dev/null
- This file is part of Red Hat elfutils.
+/* Relocation handling for DWARF reader.
+ Copyright (C) 2010 Red Hat, Inc.
- Red Hat elfutils is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by the
- Free Software Foundation; version 2 of the License.
+
- Red Hat elfutils is distributed in the hope that it will be useful, but
++ This file is part of elfutils.
+
- You should have received a copy of the GNU General Public License along
- with Red Hat elfutils; if not, write to the Free Software Foundation,
- Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
-
- In addition, as a special exception, Red Hat, Inc. gives You the
- additional right to link the code of Red Hat elfutils with code licensed
- under any Open Source Initiative certified open source license
- (http://www.opensource.org/licenses/index.php) which requires the
- distribution of source code with any binary distribution and to
- distribute linked combinations of the two. Non-GPL Code permitted under
- this exception must only link to the code of Red Hat elfutils through
- those well defined interfaces identified in the file named EXCEPTION
- found in the source code files (the "Approved Interfaces"). The files
- of Non-GPL Code may instantiate templates or use macros or inline
- functions from the Approved Interfaces without causing the resulting
- work to be covered by the GNU General Public License. Only Red Hat,
- Inc. may make changes or additions to the list of Approved Interfaces.
- Red Hat's grant of this exception is conditioned upon your not adding
- any new exceptions. If you wish to add a new Approved Interface or
- exception, please contact Red Hat. You must obey the GNU General Public
- License in all respects for all of the Red Hat elfutils code and other
- code used in conjunction with Red Hat elfutils except the Non-GPL Code
- covered by this exception. If you modify this file, you may extend this
- exception to your version of the file, but you are not obligated to do
- so. If you do not wish to provide this exception without modification,
- you must delete this exception statement from your version and license
- this file solely under the GPL without exception.
-
- Red Hat elfutils is an included package of the Open Invention Network.
- An included package of the Open Invention Network is a package for which
- Open Invention Network licensees cross-license their patents. No patent
- license is granted, either expressly or impliedly, by designation as an
- included package. Should you wish to participate in the Open Invention
- Network licensing program, please visit www.openinventionnetwork.com
- <http://www.openinventionnetwork.com>. */
++ This file is free software; you can redistribute it and/or modify
++ it under the terms of either
++
++ * the GNU Lesser General Public License as published by the Free
++ Software Foundation; either version 3 of the License, or (at
++ your option) any later version
++
++ or
++
++ * the GNU General Public License as published by the Free
++ Software Foundation; either version 2 of the License, or (at
++ your option) any later version
++
++ or both in parallel, as here.
++
++ elfutils is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
++ You should have received copies of the GNU General Public License and
++ the GNU Lesser General Public License along with this program. If
++ not, see <http://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "relocate.h"
+#include "../libebl/libebl.h"
+#include <dwarf.h>
+#include <assert.h>
+#include <stdlib.h>
+
+
+void
+internal_function
+__libdw_relocate_begin (Dwarf *dbg, Elf_Scn *relscn[IDX_last], bool incomplete)
+{
+ if (incomplete)
+ {
+ /* We may need a second pass to identify some relocation sections. */
+
+ Elf_Scn *scn = NULL;
+ while ((scn = elf_nextscn (dbg->elf, scn)) != NULL)
+ {
+ GElf_Shdr shdr_mem;
+ GElf_Shdr *shdr;
+ shdr = gelf_getshdr (scn, &shdr_mem);
+ assert (shdr == &shdr_mem);
+ if ((shdr->sh_type == SHT_REL || shdr->sh_type == SHT_RELA)
+ && shdr->sh_size != 0)
+ for (size_t i = 0; i < IDX_last; ++i)
+ if (relscn[i] == NULL && dbg->sectiondata[i] != NULL
+ && (((Elf_Data_Scn * ) dbg->sectiondata[i])->s->index
+ == shdr->sh_link))
+ relscn[i] = scn;
+ }
+ }
+
+ dbg->relocate = libdw_typed_alloc (dbg, struct dwarf_file_reloc);
+ dbg->relocate->ebl = NULL;
+ dbg->relocate->dwflmod = NULL;
+
+ /* All we do to start with is cache the section pointers.
+ We'll do the rest on demand in digest_relocs, below. */
+ for (size_t i = 0; i < IDX_last; ++i)
+ if (relscn[i] == NULL)
+ dbg->relocate->sectionrel[i] = NULL;
+ else
+ (dbg->relocate->sectionrel[i]
+ = libdw_typed_alloc (dbg, struct dwarf_section_reloc))->scn = relscn[i];
+}
+
+void
+internal_function
+__libdw_relocate_end (Dwarf *dbg)
+{
+ ebl_closebackend (dbg->relocate->ebl);
+}
+\f
+struct digested_reloc
+{
+ GElf_Sxword addend;
+ const unsigned char *datum;
+ int symndx;
+ bool rel8;
+};
+
+static bool
+match_r_type (const int *types, int r_type)
+{
+ for (const int *t = types; *t != 0; ++t)
+ if (r_type == *t)
+ return true;
+ return false;
+}
+
+static inline int
+digest_one_reloc (const int *rel8_types, const int *rel4_types,
+ struct dwarf_section_reloc *r, Elf_Data *data,
+ GElf_Addr *sorted, struct digested_reloc **digest,
+ GElf_Addr r_offset, GElf_Xword r_info, GElf_Sxword r_addend)
+{
+ const int r_type = GELF_R_TYPE (r_info);
+ int symndx = GELF_R_SYM (r_info);
+
+ size_t *nrel = &r->rel8.n;
+ if (match_r_type (rel8_types, r_type))
+ (*digest)->rel8 = true;
+ else if (unlikely (!match_r_type (rel4_types, r_type)))
+ return DWARF_E_RELBADTYPE;
+ else if (unlikely ((GElf_Sxword) (GElf_Sword) r_addend != r_addend))
+ return DWARF_E_RELBADADDEND;
+ else
+ {
+ (*digest)->rel8 = false;
+ nrel = &r->rel4.n;
+ }
+
+ if (unlikely (data->d_size - ((*digest)->rel8 ? 8 : 4) < r_offset))
+ return DWARF_E_RELBADOFF;
+
+ /* Fetch the symbol used in the reloc. STN_UNDEF means no symbol,
+ just an addend in some unallocated target DWARF section. If the
+ symbol is defined non-weak in another unallocated section, we can
+ adjust the addend now and not bother to record any symbol. */
+
+ inline bool allocated_scn (GElf_Word shndx)
+ {
+ Elf_Scn *const symscn = ((Elf_Data_Scn *) r->symdata)->s;
+ GElf_Shdr shdr;
+ return (gelf_getshdr (elf_getscn (symscn->elf, shndx), &shdr) == NULL
+ || (shdr.sh_flags & SHF_ALLOC));
+ }
+
+ GElf_Sym sym;
+ Elf32_Word shndx;
+ if (symndx != STN_UNDEF
+ && gelf_getsymshndx (r->symdata, r->symxndxdata, symndx, &sym, &shndx)
+ && GELF_ST_BIND (sym.st_info) < STB_WEAK
+ && (sym.st_shndx == SHN_XINDEX ? !allocated_scn (shndx)
+ : (sym.st_shndx != SHN_UNDEF
+ && sym.st_shndx < SHN_LORESERVE
+ && !allocated_scn (sym.st_shndx))))
+ {
+ r_addend += sym.st_value;
+ symndx = STN_UNDEF;
+ }
+
+#if 0
+ // XXX do in separate pass only for unstrip -R
+ if (modify && symndx == STN_UNDEF)
+ {
+ /* This is fully resolved statically.
+ Modify it in place and record nothing. */
+
+ unsigned char *datum = (unsigned char *) (*digest)->datum;
+ if ((*digest)->rel8)
+ {
+ Elf64_Xword val = read_8ubyte_unaligned (dbg, datum) + r_addend;
+ if (dbg->other_byte_order)
+ val = bswap_64 (val);
+ memcpy (datum, &val, sizeof val);
+ }
+ else
+ {
+ Elf32_Word val = read_4ubyte_unaligned (dbg, datum) + r_addend;
+ if (dbg->other_byte_order)
+ val = bswap_32 (val);
+ memcpy (datum, &val, sizeof val);
+ }
+ return 0;
+ }
+#endif
+
+ if (r_addend != 0 || symndx != STN_UNDEF)
+ {
+ /* This will require relocating the data dynamically. Record it. */
+
+ (*digest)->datum = data->d_buf + r_offset;
+ (*digest)->symndx = symndx;
+ (*digest)->addend = r_addend;
+ ++*digest;
+ ++*nrel;
+
+ /* Record the largest offset yet seen, or -1 if we moved backwards. */
+ if (r_offset < *sorted)
+ *sorted = -1;
+ else
+ *sorted = r_offset;
+ }
+
+ return 0;
+}
+
+static int
+compare_digested_reloc (const void *a, const void *b)
+{
+ const struct digested_reloc *const *r1 = a;
+ const struct digested_reloc *const *r2 = b;
+ return (*r1)->datum > (*r2)->datum ? 1 : (*r1)->datum < (*r2)->datum ? -1 : 0;
+}
+
+static int
+digest_relocs (Dwarf *dbg, Elf_Data *data, struct dwarf_section_reloc *r)
+{
+ GElf_Shdr shdr;
+ if (unlikely (gelf_getshdr (r->scn, &shdr) == NULL))
+ assert (!"impossible gelf_getshdr failure");
+
+ /* Look for the symtab section this reloc section refers to. */
+ GElf_Shdr symshdr;
+ Elf_Scn *const symscn = elf_getscn (r->scn->elf, shdr.sh_link);
+ if (likely (gelf_getshdr (symscn, &symshdr) != NULL)
+ && symshdr.sh_type != SHT_NOBITS)
+ {
+ r->symdata = elf_getdata (symscn, NULL);
+ r->symstrdata = elf_getdata (elf_getscn (r->scn->elf, symshdr.sh_link),
+ NULL);
+ }
+
+ /* Let libdwfl set up ebl and symtab pointers if it can. */
+ if (dbg->relocate->dwflmod != NULL)
+ __libdwfl_relocate_setup (dbg, r);
+
+ /* Fail if neither direct pointers nor libdwfl backup found a symtab. */
+ if (unlikely (r->symdata == NULL) || unlikely (r->symstrdata == NULL))
+ return DWARF_E_RELBADSYM;
+
+ if (dbg->relocate->ebl == NULL)
+ {
+ dbg->relocate->ebl = ebl_openbackend (dbg->elf);
+ if (unlikely (dbg->relocate->ebl == NULL))
+ return DWARF_E_NOMEM;
+ }
+
+ const int *rel8_types;
+ const int *rel4_types;
+ ebl_reloc_simple_types (dbg->relocate->ebl, &rel8_types, &rel4_types);
+
+ Elf_Data *const reldata = elf_getdata (r->scn, NULL);
+
+ const size_t nrel = shdr.sh_size / shdr.sh_entsize;
+ struct digested_reloc digest[nrel];
+ struct digested_reloc *d = digest;
+
+ r->rel4.n = r->rel8.n = 0;
+
+ GElf_Addr sorted = 0;
+
+ int ret = 0;
+ if (shdr.sh_type == SHT_RELA)
+ for (size_t i = 0; i < nrel && !ret; ++i)
+ {
+ GElf_Rela rela;
+ if (unlikely (gelf_getrela (reldata, i, &rela) == NULL))
+ assert (!"impossible gelf_getrela failure");
+ ret = digest_one_reloc (rel8_types, rel4_types, r, data, &sorted, &d,
+ rela.r_offset, rela.r_info, rela.r_addend);
+ }
+ else
+ for (size_t i = 0; i < nrel && !ret; ++i)
+ {
+ GElf_Rel rel;
+ if (unlikely (gelf_getrel (reldata, i, &rel) == NULL))
+ assert (!"impossible gelf_getrel failure");
+ ret = digest_one_reloc (rel8_types, rel4_types, r, data, &sorted, &d,
+ rel.r_offset, rel.r_info, 0);
+ }
+
+ assert (r->rel4.n + r->rel8.n == (size_t) (d - digest));
+
+ if (ret)
+ return ret;
+
+ if (r->rel8.n > 0)
+ {
+ r->rel8.datum = libdw_alloc (dbg, const unsigned char *,
+ sizeof (const unsigned char *),
+ r->rel8.n);
+ r->rel8.symndx = libdw_alloc (dbg, int, sizeof (int), r->rel8.n);
+ if (shdr.sh_type == SHT_RELA)
+ r->rela8 = libdw_alloc (dbg, Elf64_Sxword, sizeof (Elf64_Sxword),
+ r->rel8.n);
+ else
+ r->rela8 = NULL;
+ }
+
+ if (r->rel4.n > 0)
+ {
+ r->rel4.datum = libdw_alloc (dbg, const unsigned char *,
+ sizeof (const unsigned char *),
+ r->rel4.n);
+ r->rel4.symndx = libdw_alloc (dbg, int, sizeof (int), r->rel4.n);
+ if (shdr.sh_type == SHT_RELA)
+ r->rela4 = libdw_alloc (dbg, Elf32_Sword, sizeof (Elf32_Sword),
+ r->rel4.n);
+ else
+ r->rela4 = NULL;
+ }
+
+ size_t n8 = 0;
+ size_t n4 = 0;
+
+ inline void reify_reloc (struct digested_reloc *dr)
+ {
+ if (dr->rel8)
+ {
+ r->rel8.datum[n8] = dr->datum;
+ r->rel8.symndx[n8] = dr->symndx;
+ if (shdr.sh_type == SHT_RELA)
+ r->rela8[n8] = dr->addend;
+ ++n8;
+ }
+ else
+ {
+ r->rel4.datum[n4] = dr->datum;
+ r->rel4.symndx[n4] = dr->symndx;
+ if (shdr.sh_type == SHT_RELA)
+ r->rela4[n4] = dr->addend;
+ ++n4;
+ }
+ }
+
+ if (sorted != (GElf_Addr) -1)
+ {
+ /* The records were already sorted in the file. */
+ for (struct digested_reloc *dr = digest; dr < d; ++dr)
+ reify_reloc (dr);
+ }
+ else
+ {
+ /* qsort is much faster when it only copies pointers.
+ So make another array of pointers for the sorting. */
+
+ struct digested_reloc *sort_digest[d - digest];
+ for (size_t i = 0; i < (size_t) (d - digest); ++i)
+ sort_digest[i] = &digest[i];
+
+ /* Sort by datum address. */
+ qsort (sort_digest, d - digest, sizeof sort_digest[0],
+ &compare_digested_reloc);
+
+ for (size_t i = 0; i < (size_t) (d - digest); ++i)
+ reify_reloc (sort_digest[i]);
+ }
+
+ assert (n8 == r->rel8.n);
+ assert (n4 == r->rel4.n);
+
+ /* Clearing this marks that the digested form is set up now. */
+ r->scn = NULL;
+ return 0;
+}
+\f
+/* Binary search for an exact match on the DATUM address. */
+static ssize_t
+find_reloc (struct dwarf_reloc_table *table, const unsigned char *datum)
+{
+ size_t l = 0, u = table->n;
+
+ if (u == 0)
+ return -1;
+
+ if (table->hint < u && table->datum[table->hint] <= datum)
+ {
+ l = table->hint;
+ if (table->datum[l] == datum)
+ return l;
+ if (table->datum[l] < datum)
+ ++l;
+ }
+
+ while (l < u)
+ {
+ size_t i = (l + u) / 2;
+ if (table->datum[i] < datum)
+ l = i + 1;
+ else if (table->datum[i] > datum)
+ u = i;
+ else
+ return table->hint = i;
+ }
+
+ table->hint = l;
+ return -1;
+}
+
+int
+internal_function
+__libdw_relocatable (Dwarf *dbg, int sec_index,
+ const unsigned char *datum, int width,
+ int *symndx, GElf_Sxword *addend)
+{
+ if (dbg->relocate == NULL)
+ {
+ noreloc:
+ if (addend != NULL)
+ *addend = (width == 8
+ ? read_8ubyte_unaligned (dbg, datum)
+ : read_4ubyte_unaligned (dbg, datum));
+ return 0;
+ }
+
+ struct dwarf_section_reloc *const r = dbg->relocate->sectionrel[sec_index];
+ if (r == NULL)
+ goto noreloc;
+
+ if (r->scn != NULL)
+ {
+ int result = digest_relocs (dbg, dbg->sectiondata[sec_index], r);
+ if (unlikely (result != 0))
+ {
+ __libdw_seterrno (result);
+ return -1;
+ }
+ }
+
+ ssize_t i;
+ if (width == 4)
+ {
+ i = find_reloc (&r->rel4, datum);
+ if (symndx != NULL)
+ *symndx = i < 0 ? STN_UNDEF : r->rel4.symndx[i];
+ if (addend != NULL)
+ *addend = ((i < 0 || r->rela4 == NULL)
+ ? read_4sbyte_unaligned (dbg, datum) : r->rela4[i]);
+ }
+ else
+ {
+ assert (width == 8);
+
+ i = find_reloc (&r->rel8, datum);
+ if (symndx != NULL)
+ *symndx = i < 0 ? STN_UNDEF : r->rel8.symndx[i];
+ if (addend != NULL)
+ *addend = ((i < 0 || r->rela8 == NULL)
+ ? read_8sbyte_unaligned (dbg, datum) : r->rela8[i]);
+ }
+
+ return i >= 0;
+}
+
+static int
+reloc_getsym (struct dwarf_section_reloc *r, int symndx,
+ GElf_Sym *sym, GElf_Word *shndx)
+{
+ if (unlikely (gelf_getsymshndx (r->symdata, r->symxndxdata,
+ symndx, sym, shndx) == NULL))
+ {
+ __libdw_seterrno (DWARF_E_RELBADSYM);
+ return -1;
+ }
+ return 1;
+}
+
+int
+internal_function
+__libdw_relocatable_getsym (Dwarf *dbg, int sec_index,
+ const unsigned char *datum, int width,
+ int *symndx, GElf_Sym *sym, GElf_Word *shndx,
+ GElf_Sxword *addend)
+{
+ int result = __libdw_relocatable (dbg, sec_index, datum, width,
+ symndx, addend);
+ if (result > 0 && *symndx != STN_UNDEF)
+ result = reloc_getsym (dbg->relocate->sectionrel[sec_index],
+ *symndx, sym, shndx);
+ return result;
+}
+
+int
+internal_function
+__libdw_relocate_address (Dwarf *dbg, int sec_index,
+ const void *datum, int width, Dwarf_Addr *val)
+{
+ int symndx;
+ GElf_Sym sym;
+ GElf_Word shndx;
+ GElf_Sxword addend;
+ int result = __libdw_relocatable_getsym (dbg, sec_index, datum, width,
+ &symndx, &sym, &shndx, &addend);
+ if (result > 0 && symndx != STN_UNDEF)
+ result = __libdwfl_relocate_symbol
+ (dbg->relocate->sectionrel[sec_index],
+ sym.st_shndx == SHN_UNDEF || sym.st_shndx == SHN_COMMON
+ || GELF_ST_BIND (sym.st_info) > STB_WEAK,
+ dbg, &sym, sym.st_shndx == SHN_XINDEX ? shndx : sym.st_shndx, &addend);
+ if (result >= 0)
+ *val = addend;
+ return result;
+}
+
+int
+internal_function
+__libdw_relocate_offset (Dwarf *dbg, int sec_index,
+ const void *datum, int width, Dwarf_Off *val)
+{
+ int symndx;
+ GElf_Sym sym;
+ GElf_Word shndx;
+ GElf_Sxword addend;
+ int result = __libdw_relocatable_getsym (dbg, sec_index, datum, width,
+ &symndx, &sym, &shndx, &addend);
+ if (result > 0 && symndx != STN_UNDEF)
+ {
+ if (unlikely (sym.st_shndx == SHN_UNDEF)
+ || (sym.st_shndx > SHN_LORESERVE
+ && unlikely (sym.st_shndx != SHN_XINDEX)))
+ {
+ __libdw_seterrno (DWARF_E_RELUNDEF);
+ return -1;
+ }
+ if (unlikely (((Elf_Data_Scn *) dbg->sectiondata[sec_index])->s->index
+ != (sym.st_shndx == SHN_XINDEX ? shndx : sym.st_shndx)))
+ {
+ __libdw_seterrno (DWARF_E_RELWRONGSEC);
+ return -1;
+ }
+ addend += sym.st_value;
+ }
+ if (result >= 0)
+ *val = addend;
+ return result;
+}
--- /dev/null
- This file is part of Red Hat elfutils.
+/* Internal definitions for libdw relocation handling.
+ Copyright (C) 2010 Red Hat, Inc.
- Red Hat elfutils is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by the
- Free Software Foundation; version 2 of the License.
+
- Red Hat elfutils is distributed in the hope that it will be useful, but
++ This file is part of elfutils.
+
- You should have received a copy of the GNU General Public License along
- with Red Hat elfutils; if not, write to the Free Software Foundation,
- Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
-
- In addition, as a special exception, Red Hat, Inc. gives You the
- additional right to link the code of Red Hat elfutils with code licensed
- under any Open Source Initiative certified open source license
- (http://www.opensource.org/licenses/index.php) which requires the
- distribution of source code with any binary distribution and to
- distribute linked combinations of the two. Non-GPL Code permitted under
- this exception must only link to the code of Red Hat elfutils through
- those well defined interfaces identified in the file named EXCEPTION
- found in the source code files (the "Approved Interfaces"). The files
- of Non-GPL Code may instantiate templates or use macros or inline
- functions from the Approved Interfaces without causing the resulting
- work to be covered by the GNU General Public License. Only Red Hat,
- Inc. may make changes or additions to the list of Approved Interfaces.
- Red Hat's grant of this exception is conditioned upon your not adding
- any new exceptions. If you wish to add a new Approved Interface or
- exception, please contact Red Hat. You must obey the GNU General Public
- License in all respects for all of the Red Hat elfutils code and other
- code used in conjunction with Red Hat elfutils except the Non-GPL Code
- covered by this exception. If you modify this file, you may extend this
- exception to your version of the file, but you are not obligated to do
- so. If you do not wish to provide this exception without modification,
- you must delete this exception statement from your version and license
- this file solely under the GPL without exception.
-
- Red Hat elfutils is an included package of the Open Invention Network.
- An included package of the Open Invention Network is a package for which
- Open Invention Network licensees cross-license their patents. No patent
- license is granted, either expressly or impliedly, by designation as an
- included package. Should you wish to participate in the Open Invention
- Network licensing program, please visit www.openinventionnetwork.com
- <http://www.openinventionnetwork.com>. */
++ This file is free software; you can redistribute it and/or modify
++ it under the terms of either
++
++ * the GNU Lesser General Public License as published by the Free
++ Software Foundation; either version 3 of the License, or (at
++ your option) any later version
++
++ or
++
++ * the GNU General Public License as published by the Free
++ Software Foundation; either version 2 of the License, or (at
++ your option) any later version
++
++ or both in parallel, as here.
++
++ elfutils is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
++ You should have received copies of the GNU General Public License and
++ the GNU Lesser General Public License along with this program. If
++ not, see <http://www.gnu.org/licenses/>. */
+
+#include "libdwP.h"
+#include "libelfP.h"
+
+
+struct dwarf_reloc_table
+{
+ size_t n; /* Number of elements in this table. */
+ const unsigned char **datum; /* Sorted pointers into section data. */
+ int *symndx; /* Corresponding symtab indices. */
+ size_t hint; /* Index of last search. */
+};
+
+struct dwarf_section_reloc
+{
+ /* This is set only in the laziest state from startup: the reloc
+ section needs to be examined, and the rest is uninitialized.
+ When this is cleared, the rest is initialized and safe to use. */
+ Elf_Scn *scn;
+
+ Elf_Data *symdata;
+ Elf_Data *symstrdata;
+ Elf_Data *symxndxdata;
+
+ /* Two tables of predigested relocations, segregated by size. */
+ struct dwarf_reloc_table rel4;
+ struct dwarf_reloc_table rel8;
+
+ /* For SHT_RELA, a parallel table of addends.
+ For SHT_REL, these are null. */
+ Elf32_Sword *rela4;
+ Elf64_Sxword *rela8;
+};
+
+
+extern int __libdw_relocatable (Dwarf *dbg, int sec_index,
+ const unsigned char *datum, int width,
+ int *symndx, GElf_Sxword *addend)
+ __nonnull_attribute__ (1) internal_function;
+
+extern int __libdw_relocatable_getsym (Dwarf *dbg, int sec_index,
+ const unsigned char *datum, int width,
+ int *symndx, GElf_Sym *sym,
+ GElf_Word *shndx, GElf_Sxword *addend)
+ __nonnull_attribute__ (1, 3, 5, 6, 7, 8) internal_function;
+
+extern int __libdw_relocate_shndx (Dwarf *dbg,
+ GElf_Word shndx, GElf_Sxword addend,
+ Dwarf_Addr *val)
+ __nonnull_attribute__ (1, 4) internal_function;
+
+extern ptrdiff_t __libdw_ranges_relocatable (struct Dwarf_CU *cu,
+ Dwarf_Attribute *attr,
+ ptrdiff_t offset,
+ Dwarf_Relocatable *basep,
+ Dwarf_Relocatable *startp,
+ Dwarf_Relocatable *endp,
+ Dwarf_Block *exprloc)
+ __nonnull_attribute__ (1, 4, 5, 6) internal_function;
+
+extern void __libdwfl_relocate_setup (Dwarf *dbg, struct dwarf_section_reloc *r)
+ __nonnull_attribute__ (1, 2) internal_function;
+
+extern int __libdwfl_relocate_symbol (struct dwarf_section_reloc *r, bool undef,
+ Dwarf *dbg, GElf_Sym *sym,
+ GElf_Word shndx, GElf_Sxword *addend)
+ __nonnull_attribute__ (1, 3, 4) internal_function;
/* Get information from a source line record returned by libdwfl.
- Copyright (C) 2005-2010 Red Hat, Inc.
+ Copyright (C) 2005-2011 Red Hat, Inc.
- This file is part of Red Hat elfutils.
+ This file is part of elfutils.
- Red Hat elfutils is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by the
- Free Software Foundation; version 2 of the License.
+ This file is free software; you can redistribute it and/or modify
+ it under the terms of either
- Red Hat elfutils is distributed in the hope that it will be useful, but
+ * the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 3 of the License, or (at
+ your option) any later version
+
+ or
+
+ * the GNU General Public License as published by the Free
+ Software Foundation; either version 2 of the License, or (at
+ your option) any later version
+
+ or both in parallel, as here.
+
+ elfutils is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
/* Maintenance of module list in libdwfl.
- Copyright (C) 2005, 2006, 2007, 2008 Red Hat, Inc.
+ Copyright (C) 2005-2010 Red Hat, Inc.
- This file is part of Red Hat elfutils.
+ This file is part of elfutils.
- Red Hat elfutils is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by the
- Free Software Foundation; version 2 of the License.
+ This file is free software; you can redistribute it and/or modify
+ it under the terms of either
- Red Hat elfutils is distributed in the hope that it will be useful, but
+ * the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 3 of the License, or (at
+ your option) any later version
+
+ or
+
+ * the GNU General Public License as published by the Free
+ Software Foundation; either version 2 of the License, or (at
+ your option) any later version
+
+ or both in parallel, as here.
+
+ elfutils is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
/* Find matching source locations in a module.
- Copyright (C) 2005 Red Hat, Inc.
+ Copyright (C) 2005-2010 Red Hat, Inc.
- This file is part of Red Hat elfutils.
+ This file is part of elfutils.
- Red Hat elfutils is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by the
- Free Software Foundation; version 2 of the License.
+ This file is free software; you can redistribute it and/or modify
+ it under the terms of either
- Red Hat elfutils is distributed in the hope that it will be useful, but
+ * the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 3 of the License, or (at
+ your option) any later version
+
+ or
+
+ * the GNU General Public License as published by the Free
+ Software Foundation; either version 2 of the License, or (at
+ your option) any later version
+
+ or both in parallel, as here.
+
+ elfutils is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
- You should have received a copy of the GNU General Public License along
- with Red Hat elfutils; if not, write to the Free Software Foundation,
- Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
-
- In addition, as a special exception, Red Hat, Inc. gives You the
- additional right to link the code of Red Hat elfutils with code licensed
- under any Open Source Initiative certified open source license
- (http://www.opensource.org/licenses/index.php) which requires the
- distribution of source code with any binary distribution and to
- distribute linked combinations of the two. Non-GPL Code permitted under
- this exception must only link to the code of Red Hat elfutils through
- those well defined interfaces identified in the file named EXCEPTION
- found in the source code files (the "Approved Interfaces"). The files
- of Non-GPL Code may instantiate templates or use macros or inline
- functions from the Approved Interfaces without causing the resulting
- work to be covered by the GNU General Public License. Only Red Hat,
- Inc. may make changes or additions to the list of Approved Interfaces.
- Red Hat's grant of this exception is conditioned upon your not adding
- any new exceptions. If you wish to add a new Approved Interface or
- exception, please contact Red Hat. You must obey the GNU General Public
- License in all respects for all of the Red Hat elfutils code and other
- code used in conjunction with Red Hat elfutils except the Non-GPL Code
- covered by this exception. If you modify this file, you may extend this
- exception to your version of the file, but you are not obligated to do
- so. If you do not wish to provide this exception without modification,
- you must delete this exception statement from your version and license
- this file solely under the GPL without exception.
-
- Red Hat elfutils is an included package of the Open Invention Network.
- An included package of the Open Invention Network is a package for which
- Open Invention Network licensees cross-license their patents. No patent
- license is granted, either expressly or impliedly, by designation as an
- included package. Should you wish to participate in the Open Invention
- Network licensing program, please visit www.openinventionnetwork.com
- <http://www.openinventionnetwork.com>. */
+ You should have received copies of the GNU General Public License and
+ the GNU Lesser General Public License along with this program. If
+ not, see <http://www.gnu.org/licenses/>. */
#include "libdwflP.h"
+#include "../libdw/relocate.h"
typedef uint8_t GElf_Byte;
/* Check relocation type for simple types.
- Copyright (C) 2005 Red Hat, Inc.
+ Copyright (C) 2010 Red Hat, Inc.
- This file is part of Red Hat elfutils.
+ This file is part of elfutils.
- Red Hat elfutils is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by the
- Free Software Foundation; version 2 of the License.
+ This file is free software; you can redistribute it and/or modify
+ it under the terms of either
- Red Hat elfutils is distributed in the hope that it will be useful, but
+ * the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 3 of the License, or (at
+ your option) any later version
+
+ or
+
+ * the GNU General Public License as published by the Free
+ Software Foundation; either version 2 of the License, or (at
+ your option) any later version
+
+ or both in parallel, as here.
+
+ elfutils is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
+ 2012-05-09 Roland McGrath <roland@hack.frob.com>
+
+ * elflint (check_sections): Allow zero sized sections at (filesz) end
+ of segment. And make check overflow-proofed.
+
+ 2012-04-24 Mark Wielaard <mjw@redhat.com>
+
+ * readelf.c (print_ops): Add DW_OP_GNU_push_tls_address,
+ DW_OP_GNU_uinit and DW_OP_GNU_encoded_addr.
+
+ 2012-03-28 Roland McGrath <roland@hack.frob.com>
+
+ * elflint.c (special_sections): Accept SHF_INFO_LINK for reloc sections.
+
+2012-03-30 Mark Wielaard <mjw@redhat.com>
+
+ * strip.c (handle_elf): Use ebl_reloc_simple_types instead of
+ removed ebl_reloc_simple_type.
+
2012-03-28 Mark Wielaard <mjw@redhat.com>
* readelf.c (print_debug_abbrev_section): Check there is Dwarf
-/* Copyright (C) 2005 Red Hat, Inc.
+/* Test program translating source lines into addresses.
+ Copyright (C) 2005-2010 Red Hat, Inc.
- This file is part of Red Hat elfutils.
+ This file is part of elfutils.
- Red Hat elfutils is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by the
- Free Software Foundation; version 2 of the License.
+ This file is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
- Red Hat elfutils is distributed in the hope that it will be useful, but
+ elfutils is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
- You should have received a copy of the GNU General Public License along
- with Red Hat elfutils; if not, write to the Free Software Foundation,
- Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
-
- Red Hat elfutils is an included package of the Open Invention Network.
- An included package of the Open Invention Network is a package for which
- Open Invention Network licensees cross-license their patents. No patent
- license is granted, either expressly or impliedly, by designation as an
- included package. Should you wish to participate in the Open Invention
- Network licensing program, please visit www.openinventionnetwork.com
- <http://www.openinventionnetwork.com>. */
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifdef HAVE_CONFIG_H
# include <config.h>