diff options
author | Cyrill Gorcunov <gorcunov@gmail.com> | 2009-11-29 23:21:16 +0300 |
---|---|---|
committer | Cyrill Gorcunov <gorcunov@gmail.com> | 2009-12-10 00:36:37 +0300 |
commit | 2ddcd03900d134772e98acf8cab17a12cc0c3f2a (patch) | |
tree | 498309c9e555bc6676e42ed41f7feeb2c93f5761 /output | |
parent | 6531d6d159af0d51e519c0305843bed03c77d97b (diff) | |
download | nasm-2ddcd03900d134772e98acf8cab17a12cc0c3f2a.tar.gz nasm-2ddcd03900d134772e98acf8cab17a12cc0c3f2a.tar.bz2 nasm-2ddcd03900d134772e98acf8cab17a12cc0c3f2a.zip |
Elf: bind labels to text section by default
In case if SECTION directive is omitted but the real
code exist we form .text section by default and put compiled
code here. In turn labels are not handled in a same manner.
So lets bind them to text section by default as well.
[ BR: 2835192 ]
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Diffstat (limited to 'output')
-rw-r--r-- | output/outelf32.c | 23 | ||||
-rw-r--r-- | output/outelf64.c | 23 |
2 files changed, 24 insertions, 22 deletions
diff --git a/output/outelf32.c b/output/outelf32.c index de31805..1625fb7 100644 --- a/output/outelf32.c +++ b/output/outelf32.c @@ -523,19 +523,20 @@ static void elf_deflabel(char *name, int32_t segment, int64_t offset, else { int i; sym->section = SHN_UNDEF; - if (nsects == 0 && segment == def_seg) { + if (segment == def_seg) { + /* we have to be sure at least text section is there */ int tempint; - if (segment != elf_section_names(".text", 2, &tempint)) - nasm_error(ERR_PANIC, - "strange segment conditions in ELF driver"); - sym->section = nsects; - } else { - for (i = 0; i < nsects; i++) - if (segment == sects[i]->index) { - sym->section = i + 1; - break; - } + elf_section_names(".text", 2, &tempint); } + 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) { diff --git a/output/outelf64.c b/output/outelf64.c index ba049b1..18508fb 100644 --- a/output/outelf64.c +++ b/output/outelf64.c @@ -527,19 +527,20 @@ static void elf_deflabel(char *name, int32_t segment, int64_t offset, else { int i; sym->section = SHN_UNDEF; - if (nsects == 0 && segment == def_seg) { + if (segment == def_seg) { + /* we have to be sure at least text section is there */ int tempint; - if (segment != elf_section_names(".text", 2, &tempint)) - nasm_error(ERR_PANIC, - "strange segment conditions in ELF driver"); - sym->section = nsects; - } else { - for (i = 0; i < nsects; i++) - if (segment == sects[i]->index) { - sym->section = i + 1; - break; - } + elf_section_names(".text", 2, &tempint); } + 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) { |