]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
Merge branch 'master' into relocate relocate
authorMark Wielaard <mjw@redhat.com>
Tue, 5 Jun 2012 21:59:17 +0000 (23:59 +0200)
committerMark Wielaard <mjw@redhat.com>
Wed, 6 Jun 2012 10:43:43 +0000 (12:43 +0200)
Signed-off-by: Richard Fontana <rfontana@redhat.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
74 files changed:
1  2 
backends/alpha_init.c
backends/alpha_symbol.c
backends/arm_init.c
backends/arm_symbol.c
backends/i386_init.c
backends/i386_symbol.c
backends/ia64_init.c
backends/ia64_symbol.c
backends/ppc64_init.c
backends/ppc64_symbol.c
backends/ppc_init.c
backends/ppc_symbol.c
backends/s390_init.c
backends/s390_symbol.c
backends/sh_init.c
backends/sh_symbol.c
backends/sparc_init.c
backends/sparc_symbol.c
backends/x86_64_init.c
backends/x86_64_symbol.c
libdw/ChangeLog
libdw/Makefile.am
libdw/cfi.c
libdw/cfi.h
libdw/cie.c
libdw/dwarf_begin_elf.c
libdw/dwarf_end.c
libdw/dwarf_error.c
libdw/dwarf_form_relocatable.c
libdw/dwarf_frame_cfa.c
libdw/dwarf_frame_register.c
libdw/dwarf_getcfi.c
libdw/dwarf_getcfi_elf.c
libdw/dwarf_getlocation.c
libdw/dwarf_getlocation_relocatable.c
libdw/dwarf_getlocation_relocatable_addr.c
libdw/dwarf_getsrc_die.c
libdw/dwarf_getsrc_file.c
libdw/dwarf_getsrc_relocatable.c
libdw/dwarf_getsrclines.c
libdw/dwarf_haspc_relocatable.c
libdw/dwarf_line_relocatable.c
libdw/dwarf_lineaddr.c
libdw/dwarf_linesrc.c
libdw/dwarf_next_cfi.c
libdw/dwarf_ranges_relocatable.c
libdw/dwarf_relocatable_info.c
libdw/encoded-value.h
libdw/fde.c
libdw/libdw.h
libdw/libdwP.h
libdw/memory-access.h
libdw/relocate.c
libdw/relocate.h
libdwfl/derelocate.c
libdwfl/dwfl_lineinfo.c
libdwfl/dwfl_module.c
libdwfl/dwfl_module_getdwarf.c
libdwfl/dwfl_module_getelf.c
libdwfl/dwfl_module_getsrc_file.c
libdwfl/dwfl_module_getsym.c
libdwfl/dwfl_report_elf.c
libdwfl/libdwflP.h
libdwfl/open.c
libdwfl/relocate.c
libebl/Makefile.am
libebl/ebl-hooks.h
libebl/eblopenbackend.c
libebl/eblrelocsimpletypes.c
libebl/libebl.h
src/ChangeLog
src/strip.c
tests/ChangeLog
tests/line2addr.c

Simple merge
index 2ccc62552c696fd389b9706874f828b153617b95,657d9eec23744ebd8dc90ebced531f0e10077b5d..9426824ef17fa966a3c4d34b8419d99d23396d32
@@@ -1,13 -1,24 +1,24 @@@
  /* 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.
Simple merge
index 0cb1054aa3cf7c634f04e0dfbfa1d651736ce9e9,e41ce347c483ce2f5f2054fcd27bee18c73ccf0c..a41ec29109424e2f294ed7d37e42b96ba0ea6489
@@@ -1,12 -1,23 +1,23 @@@
  /* 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.
Simple merge
index de14103252515b14c6f3395f841984abd35c24d9,7dbf899fd2a20598b77717fe318dba0fef364a41..2f1f60b8acedc2611896780703b15685e66b930a
@@@ -1,13 -1,24 +1,24 @@@
  /* 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.
Simple merge
index 3bcd90907760789e0dcfe61188cf0a915170541d,8d806b026254c25a86c71a828d0efb699799fde2..bbaf4a8fd8d715341707e83d7978ee0b97befbca
@@@ -1,13 -1,24 +1,24 @@@
  /* 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.
Simple merge
index d841c1ad54da011f574c4009807abf52d67889d3,244e40f8b5634f2730c5fb0419c7cebf9da2d632..b65bef6a327206ad44c844f327d2483764b5ae03
@@@ -1,13 -1,24 +1,24 @@@
  /* 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.
Simple merge
index 9110ae75b7f3f3184a1c7228474db4791c84d65c,220f243e1f9ac433caa261c9999e90d360b12a01..6515bebe80b9184e46ab52cebebf0d32c905c5f9
@@@ -1,13 -1,24 +1,24 @@@
  /* 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.
Simple merge
index e93b4412eb5fcc258282d036826dc4fba5261da9,a0a4fafaf577541e1eb948ac6871c56223ead9c3..299bd6b0757197f08ccfc5e27ab6f1960db5f337
@@@ -1,12 -1,23 +1,23 @@@
  /* 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.
Simple merge
index 48e629b8e474f8b2c0e8b8a9854aee9d59bd7197,8101e96f519e1a5691d81a34ab0d3c7d0a124280..3e3b0b6b434062fab25b9d4a4472c8bab9788857
@@@ -1,13 -1,24 +1,24 @@@
  /* 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.
Simple merge
index 713817fdc7e625113702d9fa551d5c162466e7d8,ec11dc9731af90a1a53edd0e8608f09dd4b5f150..e28ea85c1336ab73aef92b059d95b542fa135a9b
@@@ -1,13 -1,24 +1,24 @@@
  /* 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.
Simple merge
index a31fbeabe995f1ab4859ec1fdc47a1bce37df808,1622461d395b8f0d0afcf4a1494903ff4c2d2799..e849e2268c996991088858fe34c09f62d5ec7952
@@@ -1,12 -1,24 +1,24 @@@
  /* 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.
diff --cc libdw/ChangeLog
Simple merge
index 649d394ef4094479afff4e6d636c69dd84614904,e1fcef09924441313a24237a6849e258ab9f767e..6629038f1c27026da4c367f853d2973823660594
@@@ -1,13 -1,24 +1,24 @@@
  ## 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.
diff --cc libdw/cfi.c
Simple merge
diff --cc libdw/cfi.h
Simple merge
diff --cc libdw/cie.c
Simple merge
Simple merge
Simple merge
index 503c9c4c19e2e73df477d6cdbb87360a7717af31,89047dcdeffb0d11bc99e724696064801c095f33..9d44ff24670d26490126ca0033b0c9d19cc35ab4
@@@ -1,13 -1,24 +1,24 @@@
  /* 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.
index ee00522a850a643f63b924e8f03b4f02e6fde1c3,0000000000000000000000000000000000000000..271e519aead18abf1096f7ba2e8e25603ed2c832
mode 100644,000000..100644
--- /dev/null
@@@ -1,74 -1,0 +1,54 @@@
-    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)
Simple merge
Simple merge
index 91e179f370cf398a6673e1a86bb1214bb9a07bda,a49a9f06650dd189211eac7cc2a834693cded073..ee06abdc681cfd5b2526d615f61ed178b50d25f3
@@@ -1,12 -1,23 +1,23 @@@
  /* 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.
Simple merge
Simple merge
index f2082d9d7260a54bc7929570e92dcba9e2938bea,0000000000000000000000000000000000000000..bf1f4a53ab341eb243d76b47ba19a34ecd9fd5d5
mode 100644,000000..100644
--- /dev/null
@@@ -1,112 -1,0 +1,92 @@@
-    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;
 +}
index 0886c30b130ef497dbf3f865381b597b4a066851,0000000000000000000000000000000000000000..8ce1c45b464906316adad4119c8cb14552167039
mode 100644,000000..100644
--- /dev/null
@@@ -1,104 -1,0 +1,84 @@@
-    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;
 +}
index f82ed5bfdd74e23f49f452759ea80782a64efa6e,1914cdf74cd23473d17d04136ddcd4268ba5c5aa..7a6c3d9618e8af00c13f4815238ffa555e40af3f
@@@ -1,13 -1,24 +1,24 @@@
  /* 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.
index 57a5382ab310e4e373683bcaf3b97851629babc8,5289c7da48fd643c2d0472cfe86242a1c3a43fd3..943692cc7ab9007544356967d9112226be8d029c
@@@ -1,13 -1,24 +1,24 @@@
  /* 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.
index e677431a1178a30db07c6f32daa004cdd421c3e0,0000000000000000000000000000000000000000..9379b1ae4301d3b28dd52ab5c777c30079274998
mode 100644,000000..100644
--- /dev/null
@@@ -1,152 -1,0 +1,132 @@@
-    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;
 +}
Simple merge
index 62ba5a4288cc865f75cc1e0c12e00bfb0602a1ac,0000000000000000000000000000000000000000..7e5410b5f201b21d4aeaeffe42f0b82028312d99
mode 100644,000000..100644
--- /dev/null
@@@ -1,111 -1,0 +1,91 @@@
-    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)
index d53644b707efe379d12fe0f442ad9f847119464e,0000000000000000000000000000000000000000..9863113621310075df811dafec32140a1c3b9915
mode 100644,000000..100644
--- /dev/null
@@@ -1,78 -1,0 +1,59 @@@
-    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;
 +}
index a1dc6ec681a26a0792f2bc19e41dd632f7b558aa,4e1952d36455d70c3c5dfa7d614dad30c0914f5b..f5a4990e5c61ea6f3799f8d318a2ca5c4c341a00
@@@ -1,13 -1,24 +1,24 @@@
  /* 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.
index ad3a83bf02350c709b942cd010589399a75e6615,27b59903d07d5b51475aa2c238e5f9f987eaff09..2003fa0a4c8f474fb1cb6cc113a8f8b3940e39c6
@@@ -1,13 -1,24 +1,24 @@@
  /* 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.
Simple merge
index 61f52a45d88df23957b41fc7f465fb410574900c,0000000000000000000000000000000000000000..234c83bf92e667cf793bf19ecdb04e9d7c53c466
mode 100644,000000..100644
--- /dev/null
@@@ -1,256 -1,0 +1,236 @@@
-    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)
index 8570276c0ed3304f0db4bceea1909e5af7c971b1,0000000000000000000000000000000000000000..f7b0f8f97d106c73a2d4dc3903f45bb562a921f5
mode 100644,000000..100644
--- /dev/null
@@@ -1,187 -1,0 +1,167 @@@
-    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)
Simple merge
diff --cc libdw/fde.c
Simple merge
diff --cc libdw/libdw.h
index 4ee46b8ee37c50ea227042c001dbc52481caf5ca,f5fc4e2389b44c7673032b8bb4b90800b7141a16..d02910e20328f95a79eef4240fbb9f6df27f7be9
@@@ -1,12 -1,23 +1,23 @@@
  /* 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.
diff --cc libdw/libdwP.h
index 580e203ffe8ed97c957d236dd84b00a0a42e6809,3c1925b3cb87cc1b1826fad085610431e925b62f..b17e3e589fbbb085620619216af4625a40ace9e4
@@@ -1,13 -1,24 +1,24 @@@
  /* 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.
Simple merge
index a29797e8632407534330b02b5c13b639e8687f9a,0000000000000000000000000000000000000000..74f8b84ab4ea09d5761cb4f188c2971024af8e81
mode 100644,000000..100644
--- /dev/null
@@@ -1,551 -1,0 +1,531 @@@
-    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;
 +}
index 495558bd438320ad3fee3391607aa18a2635bf17,0000000000000000000000000000000000000000..23b302416ab34c1a9ee0364161bef50f2363ea43
mode 100644,000000..100644
--- /dev/null
@@@ -1,115 -1,0 +1,95 @@@
-    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;
Simple merge
index e517f5f9020e0f4796503fc38f8a6af711bf1ea0,dfb27d827694ef6f637a50c3d82f5bc86699c0d9..0cf1674b144ad31bc33adda44994bd6fdcf7ecdd
@@@ -1,12 -1,23 +1,23 @@@
  /* 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.
index 4dbb1fcccd7a4036ca00808e7f76d07a3dec2ae0,e703d27ed9d825171c3331db8ed0edb028ea8882..728775589666b1ee1c7ea1804aa1daf509b8d8be
@@@ -1,12 -1,23 +1,23 @@@
  /* 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.
Simple merge
Simple merge
index fe305c682aa24c0ce8d06f92bc88205f9c075328,20aa8a5fc99553b44feb39803c5c9cadb63e37bb..efb1c494ac2ea3487179a19044074a0b5f1a1e14
@@@ -1,12 -1,23 +1,23 @@@
  /* 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.
Simple merge
Simple merge
Simple merge
diff --cc libdwfl/open.c
Simple merge
index a495f8685544a04990858aa77f244d0ca265f875,2c24bd5a982903536a1d21d08057a393497937c4..6d1b0f20f2ea4a85eb9fadc0d2a5e70b71d55646
     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;
  
Simple merge
Simple merge
Simple merge
index f9f7164ac4aef2f64c04995812c4b24b2b24d86d,085fc93116376171a1b097b13f0d38f0bd3220ee..852fb59afa47edfc48d9a1b3a280c478071abaa9
@@@ -1,12 -1,23 +1,23 @@@
  /* 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.
diff --cc libebl/libebl.h
Simple merge
diff --cc src/ChangeLog
index d5a5b250365d82b4eb388cbf4092e97e8b3f733e,af1d92bd767cb404d09724e8ab830a456d58c3af..4db7155aea5ac10e57c7dafc4e227172cc0d8de4
@@@ -1,8 -1,17 +1,22 @@@
+ 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
diff --cc src/strip.c
Simple merge
diff --cc tests/ChangeLog
Simple merge
index aef129561ab8920d631c5645877506d60df9e99f,e0d65d3dc75e560a9257e09140e675dbd0d95943..560f40d60f5f46df5d28d806485a7bca3cddf9e2
@@@ -1,27 -1,18 +1,19 @@@
 -/* 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>