mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-04-18 18:50:23 +08:00
outelf: get rid of long-since-obsolete gnu extensions warning
R_386_[PC]{8,16} have been part of the official ELF32 spec for a very long time now. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
This commit is contained in:
parent
db6960c3fa
commit
e678020878
@ -810,9 +810,9 @@ Some conditions are even less severe than that: they are only
|
||||
sometimes worth mentioning to the user. Therefore NASM supports the
|
||||
\c{-w} command-line option, which enables or disables certain
|
||||
classes of assembly warning. Such warning classes are described by a
|
||||
name, for example \c{orphan-labels}; you can enable warnings of
|
||||
this class by the command-line option \c{-w+orphan-labels} and
|
||||
disable it by \c{-w-orphan-labels}.
|
||||
name, for example \c{label-orphan}; you can enable warnings of
|
||||
this class by the command-line option \c{-w+label-orphan} and
|
||||
disable it by \c{-w-label-orphan}.
|
||||
|
||||
The current \i{warning classes} are:
|
||||
|
||||
@ -1127,7 +1127,7 @@ optional. (Note that this means that if you intend to code \c{lodsb}
|
||||
alone on a line, and type \c{lodab} by accident, then that's still a
|
||||
valid source line which does nothing but define a label. Running
|
||||
NASM with the command-line option
|
||||
\I{orphan-labels}\c{-w+orphan-labels} will cause it to warn you if
|
||||
\I{label-orphan}\c{-w+orphan-labels} will cause it to warn you if
|
||||
you define a label alone on a line without a \i{trailing colon}.)
|
||||
|
||||
\i{Valid characters} in labels are letters, numbers, \c{_}, \c{$},
|
||||
@ -6090,12 +6090,11 @@ requires that it be aligned on a 4-byte boundary.
|
||||
\S{elf16} 16-bit code and ELF
|
||||
\I{ELF, 16-bit code}
|
||||
|
||||
The \c{ELF32} specification doesn't provide relocations for 8- and
|
||||
16-bit values, but the GNU \c{ld} linker adds these as an extension.
|
||||
NASM can generate GNU-compatible relocations, to allow 16-bit code to
|
||||
be linked as ELF using GNU \c{ld}. If NASM is used with the
|
||||
\c{-w+gnu-elf-extensions} option, a warning is issued when one of
|
||||
these relocations is generated.
|
||||
Older versions of the \c{ELF32} specification did not provide
|
||||
relocations for 8- and 16-bit values. It is now part of the formal
|
||||
specification, and any new enough linker should support them.
|
||||
|
||||
ELF has currently no support for segmented programming.
|
||||
|
||||
\S{elfdbg} Debug formats and ELF
|
||||
\I{ELF, debug formats}
|
||||
|
@ -1091,12 +1091,12 @@ static void elf32_out(int32_t segto, const void *data,
|
||||
|
||||
case OUT_ADDRESS:
|
||||
{
|
||||
bool gnu16 = false;
|
||||
bool err = false;
|
||||
int asize = abs((int)size);
|
||||
|
||||
addr = *(int64_t *)data;
|
||||
if (segment != NO_SEG) {
|
||||
if (segment % 2) {
|
||||
if (segment & 1) {
|
||||
nasm_nonfatal("ELF format does not support"
|
||||
" segment base references");
|
||||
} else {
|
||||
@ -1108,17 +1108,16 @@ static void elf32_out(int32_t segto, const void *data,
|
||||
*/
|
||||
switch (asize) {
|
||||
case 1:
|
||||
gnu16 = true;
|
||||
elf_add_reloc(s, segment, 0, R_386_8);
|
||||
break;
|
||||
case 2:
|
||||
gnu16 = true;
|
||||
elf_add_reloc(s, segment, 0, R_386_16);
|
||||
break;
|
||||
case 4:
|
||||
elf_add_reloc(s, segment, 0, R_386_32);
|
||||
break;
|
||||
default: /* Error issued further down */
|
||||
err = true;
|
||||
break;
|
||||
}
|
||||
} else if (wrt == elf_gotpc_sect + 1) {
|
||||
@ -1127,25 +1126,27 @@ static void elf32_out(int32_t segto, const void *data,
|
||||
* will let us have GOT relative to $. So we
|
||||
* need to fix up the data item by $-$$.
|
||||
*/
|
||||
err = asize != 4;
|
||||
addr += s->len;
|
||||
elf_add_reloc(s, segment, 0, R_386_GOTPC);
|
||||
} else if (wrt == elf_gotoff_sect + 1) {
|
||||
err = asize != 4;
|
||||
elf_add_reloc(s, segment, 0, R_386_GOTOFF);
|
||||
} else if (wrt == elf_tlsie_sect + 1) {
|
||||
err = asize != 4;
|
||||
addr = elf_add_gsym_reloc(s, segment, addr, 0,
|
||||
R_386_TLS_IE, true);
|
||||
} else if (wrt == elf_got_sect + 1) {
|
||||
err = asize != 4;
|
||||
addr = elf_add_gsym_reloc(s, segment, addr, 0,
|
||||
R_386_GOT32, true);
|
||||
} else if (wrt == elf_sym_sect + 1) {
|
||||
switch (asize) {
|
||||
case 1:
|
||||
gnu16 = true;
|
||||
addr = elf_add_gsym_reloc(s, segment, addr, 0,
|
||||
R_386_8, false);
|
||||
break;
|
||||
case 2:
|
||||
gnu16 = true;
|
||||
addr = elf_add_gsym_reloc(s, segment, addr, 0,
|
||||
R_386_16, false);
|
||||
break;
|
||||
@ -1154,6 +1155,7 @@ static void elf32_out(int32_t segto, const void *data,
|
||||
R_386_32, false);
|
||||
break;
|
||||
default:
|
||||
err = true;
|
||||
break;
|
||||
}
|
||||
} else if (wrt == elf_plt_sect + 1) {
|
||||
@ -1167,16 +1169,8 @@ static void elf32_out(int32_t segto, const void *data,
|
||||
}
|
||||
}
|
||||
|
||||
if (gnu16) {
|
||||
/*!
|
||||
*!gnu-elf-extensions [off] using 8- or 16-bit relocation in ELF32, a GNU extension
|
||||
*! warns if 8-bit or 16-bit relocations are used in the \c{elf32} output format.
|
||||
*! The GNU extensions allow this.
|
||||
*/
|
||||
nasm_warn(WARN_GNU_ELF_EXTENSIONS, "8- or 16-bit relocations "
|
||||
"in ELF32 is a GNU extension");
|
||||
} else if (asize != 4 && segment != NO_SEG) {
|
||||
nasm_nonfatal("Unsupported non-32-bit ELF relocation");
|
||||
if (err) {
|
||||
nasm_nonfatal("Unsupported %d-bit ELF relocation", asize << 3);
|
||||
}
|
||||
elf_sect_writeaddr(s, addr, asize);
|
||||
break;
|
||||
@ -1194,16 +1188,14 @@ static void elf32_out(int32_t segto, const void *data,
|
||||
rel12adr:
|
||||
addr = *(int64_t *)data - size;
|
||||
nasm_assert(segment != segto);
|
||||
if (segment != NO_SEG && segment % 2) {
|
||||
if (segment != NO_SEG && (segment & 1)) {
|
||||
nasm_nonfatal("ELF format does not support"
|
||||
" segment base references");
|
||||
} else {
|
||||
if (wrt == NO_SEG) {
|
||||
nasm_warn(WARN_GNU_ELF_EXTENSIONS, "8- or 16-bit relocations "
|
||||
"in ELF is a GNU extension");
|
||||
elf_add_reloc(s, segment, 0, reltype);
|
||||
} else {
|
||||
nasm_nonfatal("Unsupported non-32-bit ELF relocation");
|
||||
nasm_nonfatal("Unsupported %d-bit ELF relocation", bytes << 3);
|
||||
}
|
||||
}
|
||||
elf_sect_writeaddr(s, addr, bytes);
|
||||
@ -1213,7 +1205,7 @@ rel12adr:
|
||||
addr = *(int64_t *)data - size;
|
||||
if (segment == segto)
|
||||
nasm_panic("intra-segment OUT_REL4ADR");
|
||||
if (segment != NO_SEG && segment % 2) {
|
||||
if (segment != NO_SEG && (segment & 1)) {
|
||||
nasm_nonfatal("ELF format does not support"
|
||||
" segment base references");
|
||||
} else {
|
||||
@ -1311,7 +1303,7 @@ static void elf64_out(int32_t segto, const void *data,
|
||||
addr = *(int64_t *)data;
|
||||
if (segment == NO_SEG) {
|
||||
/* Do nothing */
|
||||
} else if (segment % 2) {
|
||||
} else if (segment & 1) {
|
||||
nasm_nonfatal("ELF format does not support"
|
||||
" segment base references");
|
||||
} else {
|
||||
@ -1435,15 +1427,16 @@ rel12adr:
|
||||
nasm_panic("intra-segment OUT_REL1ADR");
|
||||
if (segment == NO_SEG) {
|
||||
/* Do nothing */
|
||||
} else if (segment % 2) {
|
||||
} else if (segment & 1) {
|
||||
nasm_nonfatal("ELF format does not support"
|
||||
" segment base references");
|
||||
} else {
|
||||
if (wrt == NO_SEG) {
|
||||
elf_add_reloc(s, segment, addr, reltype);
|
||||
addr = 0;
|
||||
} else
|
||||
nasm_nonfatal("Unsupported non-32-bit ELF relocation");
|
||||
} else {
|
||||
nasm_nonfatal("Unsupported %d-bit ELF relocation", bytes << 3);
|
||||
}
|
||||
}
|
||||
elf_sect_writeaddr(s, addr, bytes);
|
||||
break;
|
||||
@ -1454,7 +1447,7 @@ rel12adr:
|
||||
nasm_panic("intra-segment OUT_REL4ADR");
|
||||
if (segment == NO_SEG) {
|
||||
/* Do nothing */
|
||||
} else if (segment % 2) {
|
||||
} else if (segment & 1) {
|
||||
nasm_nonfatal("ELF64 format does not support"
|
||||
" segment base references");
|
||||
} else {
|
||||
@ -1492,7 +1485,7 @@ rel12adr:
|
||||
nasm_panic("intra-segment OUT_REL8ADR");
|
||||
if (segment == NO_SEG) {
|
||||
/* Do nothing */
|
||||
} else if (segment % 2) {
|
||||
} else if (segment & 1) {
|
||||
nasm_nonfatal("ELF64 format does not support"
|
||||
" segment base references");
|
||||
} else {
|
||||
@ -1590,7 +1583,7 @@ static void elfx32_out(int32_t segto, const void *data,
|
||||
addr = *(int64_t *)data;
|
||||
if (segment == NO_SEG) {
|
||||
/* Do nothing */
|
||||
} else if (segment % 2) {
|
||||
} else if (segment & 1) {
|
||||
nasm_nonfatal("ELF format does not support"
|
||||
" segment base references");
|
||||
} else {
|
||||
@ -1704,15 +1697,16 @@ rel12adr:
|
||||
nasm_panic("intra-segment OUT_REL1ADR");
|
||||
if (segment == NO_SEG) {
|
||||
/* Do nothing */
|
||||
} else if (segment % 2) {
|
||||
} else if (segment & 1) {
|
||||
nasm_nonfatal("ELF format does not support"
|
||||
" segment base references");
|
||||
} else {
|
||||
if (wrt == NO_SEG) {
|
||||
elf_add_reloc(s, segment, addr, reltype);
|
||||
addr = 0;
|
||||
} else
|
||||
nasm_nonfatal("Unsupported non-32-bit ELF relocation");
|
||||
} else {
|
||||
nasm_nonfatal("unsupported %d-bit ELF relocation", bytes << 3);
|
||||
}
|
||||
}
|
||||
elf_sect_writeaddr(s, addr, bytes);
|
||||
break;
|
||||
@ -1723,7 +1717,7 @@ rel12adr:
|
||||
nasm_panic("intra-segment OUT_REL4ADR");
|
||||
if (segment == NO_SEG) {
|
||||
/* Do nothing */
|
||||
} else if (segment % 2) {
|
||||
} else if (segment & 1) {
|
||||
nasm_nonfatal("ELFX32 format does not support"
|
||||
" segment base references");
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user