From 55ecdad6ebb377adebccdf473adfcf358e9549b8 Mon Sep 17 00:00:00 2001 From: Michael Urman Date: Tue, 2 Dec 2003 06:27:53 +0000 Subject: [PATCH] Enable elf support for extended section attribute align=foo parameters. It had previously been mysteriously if(0)'d out. Reported By: Edouard Gomez svn path=/trunk/yasm/; revision=1085 --- modules/objfmts/elf/elf-objfmt.c | 44 +- modules/objfmts/elf/tests/Makefile.inc | 3 + modules/objfmts/elf/tests/elfsectalign.asm | 2 + .../objfmts/elf/tests/elfsectalign.errwarn | 0 modules/objfmts/elf/tests/elfsectalign.hex | 472 ++++++++++++++++++ 5 files changed, 498 insertions(+), 23 deletions(-) create mode 100644 modules/objfmts/elf/tests/elfsectalign.asm create mode 100644 modules/objfmts/elf/tests/elfsectalign.errwarn create mode 100644 modules/objfmts/elf/tests/elfsectalign.hex diff --git a/modules/objfmts/elf/elf-objfmt.c b/modules/objfmts/elf/elf-objfmt.c index 73429803..7e4b8b11 100644 --- a/modules/objfmts/elf/elf-objfmt.c +++ b/modules/objfmts/elf/elf-objfmt.c @@ -684,29 +684,27 @@ elf_objfmt_section_switch(yasm_object *object, yasm_valparamhead *valparams, type &= ~SHT_PROGBITS; } else if (yasm__strcasecmp(vp->val, "align") == 0 && vp->param) { - if (0 /* win32 */) { - /*@dependent@*/ /*@null@*/ const yasm_intnum *align_expr; - unsigned long addralign; - - align_expr = yasm_expr_get_intnum(&vp->param, NULL); - if (!align_expr) { - yasm__error(line, - N_("argument to `%s' is not a power of two"), - vp->val); - return NULL; - } - addralign = yasm_intnum_get_uint(align_expr); - - /* Alignments must be a power of two. */ - if ((addralign & (addralign - 1)) != 0) { - yasm__error(line, - N_("argument to `%s' is not a power of two"), - vp->val); - return NULL; - } - - align_intn = yasm_intnum_copy(align_expr); - } + /*@dependent@*/ /*@null@*/ const yasm_intnum *align_expr; + unsigned long addralign; + + align_expr = yasm_expr_get_intnum(&vp->param, NULL); + if (!align_expr) { + yasm__error(line, + N_("argument to `%s' is not a power of two"), + vp->val); + return NULL; + } + addralign = yasm_intnum_get_uint(align_expr); + + /* Alignments must be a power of two. */ + if ((addralign & (addralign - 1)) != 0) { + yasm__error(line, + N_("argument to `%s' is not a power of two"), + vp->val); + return NULL; + } + + align_intn = yasm_intnum_copy(align_expr); } else yasm__warning(YASM_WARN_GENERAL, line, N_("Unrecognized qualifier `%s'"), vp->val); diff --git a/modules/objfmts/elf/tests/Makefile.inc b/modules/objfmts/elf/tests/Makefile.inc index 822f54cf..e39e0bc3 100644 --- a/modules/objfmts/elf/tests/Makefile.inc +++ b/modules/objfmts/elf/tests/Makefile.inc @@ -3,6 +3,9 @@ TESTS += modules/objfmts/elf/tests/elf_test.sh EXTRA_DIST += modules/objfmts/elf/tests/elf_test.sh +EXTRA_DIST += modules/objfmts/elf/tests/elfsectalign.asm +EXTRA_DIST += modules/objfmts/elf/tests/elfsectalign.hex +EXTRA_DIST += modules/objfmts/elf/tests/elfsectalign.errwarn EXTRA_DIST += modules/objfmts/elf/tests/elftest.c EXTRA_DIST += modules/objfmts/elf/tests/elftest.asm EXTRA_DIST += modules/objfmts/elf/tests/elftest.hex diff --git a/modules/objfmts/elf/tests/elfsectalign.asm b/modules/objfmts/elf/tests/elfsectalign.asm new file mode 100644 index 00000000..7ed5cf89 --- /dev/null +++ b/modules/objfmts/elf/tests/elfsectalign.asm @@ -0,0 +1,2 @@ +[section .data align=64] +[section .rodata align=32] diff --git a/modules/objfmts/elf/tests/elfsectalign.errwarn b/modules/objfmts/elf/tests/elfsectalign.errwarn new file mode 100644 index 00000000..e69de29b diff --git a/modules/objfmts/elf/tests/elfsectalign.hex b/modules/objfmts/elf/tests/elfsectalign.hex new file mode 100644 index 00000000..2181bfbf --- /dev/null +++ b/modules/objfmts/elf/tests/elfsectalign.hex @@ -0,0 +1,472 @@ +7f +45 +4c +46 +01 +01 +01 +00 +00 +00 +00 +00 +00 +00 +00 +00 +01 +00 +03 +00 +01 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +c0 +00 +00 +00 +00 +00 +00 +00 +34 +00 +00 +00 +00 +00 +28 +00 +07 +00 +01 +00 +00 +2e +74 +65 +78 +74 +00 +2e +64 +61 +74 +61 +00 +2e +72 +6f +64 +61 +74 +61 +00 +2e +73 +74 +72 +74 +61 +62 +00 +2e +73 +79 +6d +74 +61 +62 +00 +2e +73 +68 +73 +74 +72 +74 +61 +62 +00 +00 +00 +2d +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +01 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +04 +00 +f1 +ff +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +03 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +03 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +03 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +25 +00 +00 +00 +03 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +34 +00 +00 +00 +2f +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +15 +00 +00 +00 +03 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +64 +00 +00 +00 +03 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +1d +00 +00 +00 +02 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +68 +00 +00 +00 +50 +00 +00 +00 +02 +00 +00 +00 +05 +00 +00 +00 +04 +00 +00 +00 +10 +00 +00 +00 +01 +00 +00 +00 +01 +00 +00 +00 +06 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +10 +00 +00 +00 +00 +00 +00 +00 +07 +00 +00 +00 +01 +00 +00 +00 +03 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +40 +00 +00 +00 +00 +00 +00 +00 +0d +00 +00 +00 +01 +00 +00 +00 +02 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +20 +00 +00 +00 +00 +00 +00 +00 -- 2.40.0