bfd/
authorH.J. Lu <hjl.tools@gmail.com>
Wed, 30 Jun 2004 16:19:20 +0000 (16:19 +0000)
committerH.J. Lu <hjl.tools@gmail.com>
Wed, 30 Jun 2004 16:19:20 +0000 (16:19 +0000)
2004-06-30  H.J. Lu  <hongjiu.lu@intel.com>

PR 233
* elflink.c (elf_link_input_bfd): Issue an error for non-debug
local references to discarded sections and report their
locations.

ld/testsuite/

2004-06-30  H.J. Lu  <hongjiu.lu@intel.com>

PR 233
* ld-discard/extern.d: Updated.
* ld-discard/start.d: Likewise.
* ld-discard/static.d: Likewise.

bfd/ChangeLog
bfd/elflink.c
ld/testsuite/ChangeLog
ld/testsuite/ld-discard/extern.d
ld/testsuite/ld-discard/start.d
ld/testsuite/ld-discard/static.d

index 20f0c227ac34abdc237cd48e1d9676d594469fda..464821dfec69c0a1e0d8f61bd23cf119d5a2d5ac 100644 (file)
@@ -1,3 +1,10 @@
+2004-06-30  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR 233
+       * elflink.c (elf_link_input_bfd): Issue an error for non-debug
+       local references to discarded sections and report their
+       locations.
+
 2004-06-30  Alan Modra  <amodra@bigpond.net.au>
 
        * elflink.c (elf_section_ignore_discarded_relocs): Don't test
index 354cfbbe5a5e90ce718ff23c07ea025e533ce6b2..e682758728c0501ce54f061f7a3a10a31511ac12 100644 (file)
@@ -6581,8 +6581,7 @@ elf_link_input_bfd (struct elf_final_link_info *finfo, bfd *input_bfd)
                            {
                              BFD_ASSERT (r_symndx != 0);
                              /* Try to preserve debug information.  */
-                             if ((o->flags & SEC_DEBUGGING) != 0
-                                 && sec->kept_section != NULL
+                             if (sec->kept_section != NULL
                                  && sec->size == sec->kept_section->size)
                                h->root.u.def.section
                                  = sec->kept_section;
@@ -6590,13 +6589,20 @@ elf_link_input_bfd (struct elf_final_link_info *finfo, bfd *input_bfd)
                                memset (rel, 0, sizeof (*rel));
                            }
                          else
-                           finfo->info->callbacks->error_handler
-                             (LD_DEFINITION_IN_DISCARDED_SECTION,
-                              _("%T: discarded in section `%s' from %s\n"),
-                              h->root.root.string,
-                              h->root.root.string,
-                              h->root.u.def.section->name,
-                              bfd_archive_filename (h->root.u.def.section->owner));
+                           {
+                             char *r_name
+                               = xstrdup (bfd_archive_filename (o->owner));
+                             finfo->info->callbacks->error_handler
+                               (LD_DEFINITION_IN_DISCARDED_SECTION,
+                                _("`%T' referenced in section `%s' from %s: discarded in section `%s' from %s\n"),
+                                h->root.root.string,
+                                h->root.root.string,
+                                o->name, r_name,
+                                h->root.u.def.section->name,
+                                bfd_archive_filename (h->root.u.def.section->owner));
+                             if (r_name)
+                               free (r_name);
+                           }
                        }
                    }
                  else
@@ -6605,13 +6611,11 @@ elf_link_input_bfd (struct elf_final_link_info *finfo, bfd *input_bfd)
 
                      if (sec != NULL && elf_discarded_section (sec))
                        {
-                         if ((o->flags & SEC_DEBUGGING) != 0
-                             || (sec->flags & SEC_LINK_ONCE) != 0)
+                         if ((o->flags & SEC_DEBUGGING) != 0)
                            {
                              BFD_ASSERT (r_symndx != 0);
                              /* Try to preserve debug information.  */
-                             if ((o->flags & SEC_DEBUGGING) != 0
-                                 && sec->kept_section != NULL
+                             if (sec->kept_section != NULL
                                  && sec->size == sec->kept_section->size)
                                finfo->sections[r_symndx]
                                  = sec->kept_section;
@@ -6633,8 +6637,8 @@ elf_link_input_bfd (struct elf_final_link_info *finfo, bfd *input_bfd)
                                buf = (char *) "local symbol";
                              finfo->info->callbacks->error_handler
                                (LD_DEFINITION_IN_DISCARDED_SECTION,
-                                _("%T: discarded in section `%s' from %s\n"),
-                                buf, buf, sec->name,
+                                _("`%T' referenced in section `%s': discarded in section `%s' from %s\n"),
+                                buf, buf, o->name, sec->name,
                                 bfd_archive_filename (input_bfd));
                              if (ok != -1)
                                free (buf);
index e129ab527f73fbc300823c4672e56767eadb794e..3dacd1c710a1045abd0ce46bacf078f12ba96b93 100644 (file)
@@ -1,3 +1,10 @@
+2004-06-30  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR 233
+       * ld-discard/extern.d: Updated.
+       * ld-discard/start.d: Likewise.
+       * ld-discard/static.d: Likewise.
+
 2004-06-29  J"orn Rennecke <joern.rennecke@superh.com>
 
        Actually add these files:
index 10fa0f756f16c9de4930b41fd367aa596f6673c1..df4c7d1ceabb006aa0c95db758144e7e82270acc 100644 (file)
@@ -1,3 +1,3 @@
 #source: extern.s
 #ld: -T discard.ld
-#error: data: discarded in section `\.data\.exit' from tmpdir/dump0.o
+#error: `data' referenced in section `\.text' from tmpdir/dump0.o: discarded in section `\.data\.exit' from tmpdir/dump0.o
index b8f46ae7867accadf5aa39eb8dfd02726ffa26d6..f9885d40f7bd043984bdd1397d7ff328b88d3e66 100644 (file)
@@ -1,4 +1,4 @@
 #source: start.s
 #source: exit.s
 #ld: -T discard.ld
-#error: data: discarded in section `\.data\.exit' from tmpdir/dump1.o
+#error: `data' referenced in section `\.text' from tmpdir/dump0.o: discarded in section `\.data\.exit' from tmpdir/dump1.o
index 78b89b03136a02bdd72fc1aebe45b84cdbfe3d9a..1aa44cdd1e079811e353e6990bc992a0263b8038 100644 (file)
@@ -1,3 +1,3 @@
 #source: static.s
 #ld: -T discard.ld
-#error: local symbol 0: discarded in section `\.data\.exit' from tmpdir/dump0.o
+#error: `local symbol 0' referenced in section `\.text': discarded in section `\.data\.exit' from tmpdir/dump0.o