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>
This commit is contained in:
Cyrill Gorcunov 2009-11-29 23:21:16 +03:00
parent 6531d6d159
commit 2ddcd03900
2 changed files with 24 additions and 22 deletions

View File

@ -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) {

View File

@ -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) {