Elf: Allow symbols binding to undefined section
authorCyrill Gorcunov <gorcunov@gmail.com>
Sat, 2 Jan 2010 20:00:43 +0000 (23:00 +0300)
committerCyrill Gorcunov <gorcunov@gmail.com>
Sat, 2 Jan 2010 20:00:43 +0000 (23:00 +0300)
Commit 2ddcd03900d134772e98acf8cab17a12cc0c3f2a
did bind symbols (in case of omitted SECTION directive)
to .text section but break COMMON binding.
Fix it.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
output/outelf32.c
output/outelf64.c

index 1625fb7..6e2ae82 100644 (file)
@@ -526,17 +526,15 @@ static void elf_deflabel(char *name, int32_t segment, int64_t offset,
         if (segment == def_seg) {
             /* we have to be sure at least text section is there */
             int tempint;
-            elf_section_names(".text", 2, &tempint);
+            if (segment != elf_section_names(".text", 2, &tempint))
+                nasm_error(ERR_PANIC, "strange segment conditions in ELF driver");
         }
-        sym->section = nsects;
         for (i = 0; i < nsects; i++) {
             if (segment == sects[i]->index) {
                 sym->section = i + 1;
                 break;
             }
         }
-        if (nsects && i == nsects)
-            nasm_error(ERR_PANIC, "strange segment conditions in ELF driver");
     }
 
     if (is_global == 2) {
index 18508fb..1fcd0b3 100644 (file)
@@ -530,17 +530,15 @@ static void elf_deflabel(char *name, int32_t segment, int64_t offset,
         if (segment == def_seg) {
             /* we have to be sure at least text section is there */
             int tempint;
-            elf_section_names(".text", 2, &tempint);
+            if (segment != elf_section_names(".text", 2, &tempint))
+                nasm_error(ERR_PANIC, "strange segment conditions in ELF driver");
         }
-        sym->section = nsects;
         for (i = 0; i < nsects; i++) {
             if (segment == sects[i]->index) {
                 sym->section = i + 1;
                 break;
             }
         }
-        if (nsects && i == nsects)
-            nasm_error(ERR_PANIC, "strange segment conditions in ELF driver");
     }
 
     if (is_global == 2) {