]> granicus.if.org Git - yasm/commitdiff
Fix common and 0-offset local definition of symbol. The symbol would end
authorPeter Johnson <peter@tortall.net>
Sun, 6 Nov 2005 20:27:49 +0000 (20:27 -0000)
committerPeter Johnson <peter@tortall.net>
Sun, 6 Nov 2005 20:27:49 +0000 (20:27 -0000)
up with the alignment as the offset rather than 0.  The cause of this was
that elf_sym_set_nonzero was getting a 0 offset which it then did not set.

* elf.c (elf_symtab_set_nonzero): Make value a pointer so that 0 values
can actually get set if necessary.
* elf.h (elf_symtab_set_nonzero): Update prototype.
* elf-objfmt.c (elf_objfmt_symtab_append): Likewise, and ripple changes.

* elf_gas64_reloc.hex: Update (now is correct).

svn path=/trunk/yasm/; revision=1313

modules/objfmts/elf/elf-objfmt.c
modules/objfmts/elf/elf.c
modules/objfmts/elf/elf.h
modules/objfmts/elf/tests/gas64/elf_gas64_reloc.hex

index 29542cf261506008e74e32cf1503b64d694f426f..0f6cb79cd5986f8c0a31c2e6d74b08606eb60526 100644 (file)
@@ -89,7 +89,7 @@ static elf_symtab_entry *
 elf_objfmt_symtab_append(yasm_objfmt_elf *objfmt_elf, yasm_symrec *sym,
                         elf_section_index sectidx, elf_symbol_binding bind,
                         elf_symbol_type type, elf_symbol_vis vis,
-                         yasm_expr *size, elf_address value)
+                         yasm_expr *size, elf_address *value)
 {
     /* Only append to table if not already appended */
     elf_symtab_entry *entry = yasm_symrec_get_data(sym, &elf_symrec_data);
@@ -151,7 +151,7 @@ elf_objfmt_append_local_sym(yasm_symrec *sym, /*@null@*/ void *d)
 
     if (precbc)
        value = precbc->offset + precbc->len;
-    elf_symtab_set_nonzero(entry, sect, 0, 0, 0, NULL, value);
+    elf_symtab_set_nonzero(entry, sect, 0, 0, 0, NULL, &value);
 
     return 1;
 }
@@ -189,7 +189,8 @@ elf_objfmt_create_common(const char *in_filename, yasm_object *object,
     entry = elf_symtab_entry_create(
        elf_strtab_append_str(objfmt_elf->strtab, in_filename), filesym);
     yasm_symrec_add_data(filesym, &elf_symrec_data, entry);
-    elf_symtab_set_nonzero(entry, NULL, SHN_ABS, STB_LOCAL, STT_FILE, NULL, 0);
+    elf_symtab_set_nonzero(entry, NULL, SHN_ABS, STB_LOCAL, STT_FILE, NULL,
+                          NULL);
     elf_symtab_append_entry(objfmt_elf->elf_symtab, entry);
 
     /* FIXME: misuse of NULL bytecode */
@@ -922,7 +923,7 @@ elf_objfmt_extern_declare(yasm_objfmt *objfmt, const char *name, /*@unused@*/
 
     sym = yasm_symtab_declare(objfmt_elf->symtab, name, YASM_SYM_EXTERN, line);
     elf_objfmt_symtab_append(objfmt_elf, sym, SHN_UNDEF, STB_GLOBAL,
-                             0, STV_DEFAULT, NULL, 0);
+                             0, STV_DEFAULT, NULL, NULL);
 
     if (objext_valparams) {
        yasm_valparam *vp = yasm_vps_first(objext_valparams);
@@ -987,7 +988,7 @@ elf_objfmt_global_declare(yasm_objfmt *objfmt, const char *name,
     }
 
     elf_objfmt_symtab_append(objfmt_elf, sym, SHN_UNDEF, STB_GLOBAL,
-                             type, vis, size, 0);
+                             type, vis, size, NULL);
 
     return sym;
 }
@@ -1031,7 +1032,7 @@ elf_objfmt_common_declare(yasm_objfmt *objfmt, const char *name,
     }
 
     elf_objfmt_symtab_append(objfmt_elf, sym, SHN_COMMON, STB_GLOBAL,
-                             0, STV_DEFAULT, size, addralign);
+                             0, STV_DEFAULT, size, &addralign);
 
     return sym;
 }
@@ -1104,7 +1105,7 @@ elf_objfmt_directive(yasm_objfmt *objfmt, const char *name,
        sym = yasm_symtab_declare(objfmt_elf->symtab, symname, YASM_SYM_GLOBAL,
                                  line);
        elf_objfmt_symtab_append(objfmt_elf, sym, SHN_UNDEF, STB_WEAK,
-                                0, STV_DEFAULT, NULL, 0);
+                                0, STV_DEFAULT, NULL, NULL);
     } else
        return 1;       /* unrecognized */
 
index 7b0734f90cad03bd33a2895990b47d8eed583243..58fd69661719081a8dd08916236d69b3c0ab11c2 100644 (file)
@@ -475,7 +475,7 @@ void elf_symtab_set_nonzero(elf_symtab_entry *entry,
                            elf_symbol_binding bind,
                            elf_symbol_type type,
                            yasm_expr *xsize,
-                           elf_address value)
+                           elf_address *value)
 {
     if (!entry)
        yasm_internal_error("NULL entry");
@@ -484,7 +484,7 @@ void elf_symtab_set_nonzero(elf_symtab_entry *entry,
     if (bind) entry->bind = bind;
     if (type) entry->type = type;
     if (xsize) entry->xsize = xsize;
-    if (value) entry->value = value;
+    if (value) entry->value = *value;
 }
 
 void
index bad69b7a7965eb0c4011e4251b33716b97004753..bbd000b2ab50989f2a4159c6b0a2e005c7bb1371 100644 (file)
@@ -442,7 +442,7 @@ void elf_symtab_set_nonzero(elf_symtab_entry        *entry,
                            elf_symbol_binding   bind,
                            elf_symbol_type      type,
                            struct yasm_expr    *size,
-                           elf_address          value);
+                           elf_address         *value);
 void elf_sym_set_visibility(elf_symtab_entry    *entry,
                             elf_symbol_vis       vis);
 void elf_sym_set_type(elf_symtab_entry *entry, elf_symbol_type type);
index f26c176a305bc92a8e5d5fb7df485a58343d80ee..67cd5eb30c5fff42b9342d93c491d125fd20ee05 100644 (file)
@@ -878,7 +878,7 @@ c0
 00 
 06 
 00 
-1
+0
 00 
 00 
 00