replaced abort() with internal_error() (sf.net bug 3101319)
This commit is contained in:
+36
-56
@@ -45,6 +45,18 @@ static bool update_capacity(unsigned size, unsigned *capacity)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static __acc_cdecl_va void internal_error(const char *format, ...)
|
||||||
|
{
|
||||||
|
char buf[1024];
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
va_start(ap, format);
|
||||||
|
vsnprintf(buf, sizeof(buf), format, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
throwInternalError(buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
// Section
|
// Section
|
||||||
@@ -317,10 +329,7 @@ ElfLinker::Section *ElfLinker::findSection(const char *name, bool fatal) const
|
|||||||
if (strcmp(sections[ic]->name, name) == 0)
|
if (strcmp(sections[ic]->name, name) == 0)
|
||||||
return sections[ic];
|
return sections[ic];
|
||||||
if (fatal)
|
if (fatal)
|
||||||
{
|
internal_error("unknown section %s\n", name);
|
||||||
printf("unknown section %s\n", name);
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -330,10 +339,7 @@ ElfLinker::Symbol *ElfLinker::findSymbol(const char *name, bool fatal) const
|
|||||||
if (strcmp(symbols[ic]->name, name) == 0)
|
if (strcmp(symbols[ic]->name, name) == 0)
|
||||||
return symbols[ic];
|
return symbols[ic];
|
||||||
if (fatal)
|
if (fatal)
|
||||||
{
|
internal_error("unknown symbol %s\n", name);
|
||||||
printf("unknown symbol %s\n", name);
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -502,17 +508,11 @@ void ElfLinker::relocate()
|
|||||||
}
|
}
|
||||||
else if (strcmp(rel->value->section->name, "*UND*") == 0 &&
|
else if (strcmp(rel->value->section->name, "*UND*") == 0 &&
|
||||||
rel->value->offset == 0xdeaddead)
|
rel->value->offset == 0xdeaddead)
|
||||||
{
|
internal_error("undefined symbol '%s' referenced\n", rel->value->name);
|
||||||
printf("undefined symbol '%s' referenced\n", rel->value->name);
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
else if (rel->value->section->output == NULL)
|
else if (rel->value->section->output == NULL)
|
||||||
{
|
internal_error("can not apply reloc '%s:%x' without section '%s'\n",
|
||||||
printf("can not apply reloc '%s:%x' without section '%s'\n",
|
rel->section->name, rel->offset,
|
||||||
rel->section->name, rel->offset,
|
rel->value->section->name);
|
||||||
rel->value->section->name);
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
value = rel->value->section->offset +
|
value = rel->value->section->offset +
|
||||||
@@ -529,10 +529,7 @@ void ElfLinker::defineSymbol(const char *name, unsigned value)
|
|||||||
{
|
{
|
||||||
Symbol *symbol = findSymbol(name);
|
Symbol *symbol = findSymbol(name);
|
||||||
if (strcmp(symbol->section->name, "*ABS*") == 0)
|
if (strcmp(symbol->section->name, "*ABS*") == 0)
|
||||||
{
|
internal_error("defineSymbol: symbol '%s' is *ABS*\n", name);
|
||||||
printf("defineSymbol: symbol '%s' is *ABS*\n", name);
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
else if (strcmp(symbol->section->name, "*UND*") == 0) // for undefined symbols
|
else if (strcmp(symbol->section->name, "*UND*") == 0) // for undefined symbols
|
||||||
symbol->offset = value;
|
symbol->offset = value;
|
||||||
else if (strcmp(symbol->section->name, name) == 0) // for sections
|
else if (strcmp(symbol->section->name, name) == 0) // for sections
|
||||||
@@ -545,10 +542,7 @@ void ElfLinker::defineSymbol(const char *name, unsigned value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
internal_error("defineSymbol: symbol '%s' already defined\n", name);
|
||||||
printf("defineSymbol: symbol '%s' already defined\n", name);
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// debugging support
|
// debugging support
|
||||||
@@ -602,8 +596,7 @@ void ElfLinker::alignWithByte(unsigned len, unsigned char b)
|
|||||||
void ElfLinker::relocate1(const Relocation *rel, upx_byte *,
|
void ElfLinker::relocate1(const Relocation *rel, upx_byte *,
|
||||||
unsigned, const char *)
|
unsigned, const char *)
|
||||||
{
|
{
|
||||||
printf("unknown relocation type '%s\n", rel->type);
|
internal_error("unknown relocation type '%s\n", rel->type);
|
||||||
abort();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -616,16 +609,12 @@ void ElfLinker::relocate1(const Relocation *rel, upx_byte *,
|
|||||||
#if 0 // FIXME
|
#if 0 // FIXME
|
||||||
static void check8(const Relocation *rel, const upx_byte *location, int v, int d)
|
static void check8(const Relocation *rel, const upx_byte *location, int v, int d)
|
||||||
{
|
{
|
||||||
if (v < -128 || v > 127) {
|
if (v < -128 || v > 127)
|
||||||
printf("value out of range (%d) in reloc %s:%x\n",
|
internal_error("value out of range (%d) in reloc %s:%x\n",
|
||||||
v, rel->section->name, rel->offset);
|
v, rel->section->name, rel->offset);
|
||||||
abort();
|
if (d < -128 || d > 127)
|
||||||
}
|
internal_error("displacement target out of range (%d) in reloc %s:%x\n",
|
||||||
if (d < -128 || d > 127) {
|
v, rel->section->name, rel->offset);
|
||||||
printf("displacement target out of range (%d) in reloc %s:%x\n",
|
|
||||||
v, rel->section->name, rel->offset);
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -651,11 +640,8 @@ void ElfLinkerAMD64::relocate1(const Relocation *rel, upx_byte *location,
|
|||||||
int displ = (signed char) *location + (int) value;
|
int displ = (signed char) *location + (int) value;
|
||||||
#endif
|
#endif
|
||||||
if (displ < -128 || displ > 127)
|
if (displ < -128 || displ > 127)
|
||||||
{
|
internal_error("target out of range (%d) in reloc %s:%x\n",
|
||||||
printf("target out of range (%d) in reloc %s:%x\n",
|
displ, rel->section->name, rel->offset);
|
||||||
displ, rel->section->name, rel->offset);
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
*location += value;
|
*location += value;
|
||||||
}
|
}
|
||||||
else if (strcmp(type, "16") == 0)
|
else if (strcmp(type, "16") == 0)
|
||||||
@@ -857,19 +843,15 @@ void ElfLinkerPpc32::relocate1(const Relocation *rel, upx_byte *location,
|
|||||||
|
|
||||||
// Note that original (*location).displ is ignored.
|
// Note that original (*location).displ is ignored.
|
||||||
if (strcmp(type, "24") == 0) {
|
if (strcmp(type, "24") == 0) {
|
||||||
if (3& value) {
|
if (3& value)
|
||||||
printf("unaligned word diplacement");
|
internal_error("unaligned word diplacement");
|
||||||
abort();
|
|
||||||
}
|
|
||||||
// FIXME: displacment overflow?
|
// FIXME: displacment overflow?
|
||||||
set_be32(location, (0xfc000003 & get_be32(location)) +
|
set_be32(location, (0xfc000003 & get_be32(location)) +
|
||||||
(0x03fffffc & value));
|
(0x03fffffc & value));
|
||||||
}
|
}
|
||||||
else if (strcmp(type, "14") == 0) {
|
else if (strcmp(type, "14") == 0) {
|
||||||
if (3& value) {
|
if (3& value)
|
||||||
printf("unaligned word diplacement");
|
internal_error("unaligned word diplacement");
|
||||||
abort();
|
|
||||||
}
|
|
||||||
// FIXME: displacment overflow?
|
// FIXME: displacment overflow?
|
||||||
set_be32(location, (0xffff0003 & get_be32(location)) +
|
set_be32(location, (0xffff0003 & get_be32(location)) +
|
||||||
(0x0000fffc & value));
|
(0x0000fffc & value));
|
||||||
@@ -901,11 +883,9 @@ void ElfLinkerX86::relocate1(const Relocation *rel, upx_byte *location,
|
|||||||
#else
|
#else
|
||||||
int displ = (signed char) *location + (int) value;
|
int displ = (signed char) *location + (int) value;
|
||||||
#endif
|
#endif
|
||||||
if (range_check && (displ < -128 || displ > 127)) {
|
if (range_check && (displ < -128 || displ > 127))
|
||||||
printf("target out of range (%d,%d,%d) in reloc %s:%x\n",
|
internal_error("target out of range (%d,%d,%d) in reloc %s:%x\n",
|
||||||
displ, *location, value, rel->section->name, rel->offset);
|
displ, *location, value, rel->section->name, rel->offset);
|
||||||
abort();
|
|
||||||
}
|
|
||||||
*location += value;
|
*location += value;
|
||||||
}
|
}
|
||||||
else if (strcmp(type, "16") == 0)
|
else if (strcmp(type, "16") == 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user