mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-03-25 18:10:23 +08:00
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:
parent
6531d6d159
commit
2ddcd03900
@ -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) {
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user