Commit 5810d878 authored by Stewart Brodie's avatar Stewart Brodie
Browse files

Uses SYMDEFS files to avoid xtentries(app) and symgen.

  Fixed bug in getenv() relating to macro and numeric system variables.
Detail:
  Uses SYMDEFS file to avoid messing around with generating little text
    files, generating assembler source, assembling it etc.  abssym et al
    are construct as symbol definition template files and then updated
    directly by the linker ready for export.  The linker can use these
    files directly without needing them to be assembled into AOF format.
  Fixed getenv so that it can read macro and numeric variables.  With these
    variable types, R2 does not equal -length of the variable value, so
    trying to obtain a variable with a larger value than any previously
    read variable would fail.  This is now fixed.
  This module will refuse to build without link 5.19 or later.
Admin:
  Requires Library 0.54 or later.

  This component will not build with Library 0.53 or earlier.

Version 5.16. Tagged as 'RISC_OSLib-5_16'
parent dddff229
......@@ -62,6 +62,10 @@ OBJASM = objasm
RM = remove
WIPE = -wipe
# Note the output redirection on the end of this macro to enable parameters
# to match those of the old application xtentries.
XTENT = perl build:xtentries >
DIFF = gnu.diff -df >null:
AFLAGS = -depend !Depend -Stamp -quit
......@@ -72,6 +76,11 @@ WFLAGS = ~c~r~v
# create a new library, add symbol table
LIBFLAGS = -c -o
#
# Flags common to *all* phases of linking
#
LDFLAGS = -linkversion 519
#
# Include files
#
......@@ -456,22 +465,38 @@ dirs:
# ROM target {re-linked at ROM Image build time}
#
aof.RISC_OSLib: ${ROM_OBJS}
${LD} -o $@ -aof ${ROM_OBJS}
${LD} ${LDFLAGS} -o $@ -aof ${ROM_OBJS}
aof.CLib: ${CLIB_ROM_OBJS}
${LD} -o $@ -aof ${CLIB_ROM_OBJS}
${LD} ${LDFLAGS} -o $@ -aof ${CLIB_ROM_OBJS}
#
# Final link for the ROM Image {using given base address}
#
rom_link_RISC_OSLib: ${ROM_OBJS}
${LD} -o linked.RISC_OSLib ${ROM_OBJS} \
rom_link_Entries:
${XTENT} syms.C_Entries kernel.s.k_entries clib.s.cl_entries
print rlib.swi { >> syms.C_Entries }
| C_Entries *currently* only adds _swi/_swix to RO2 symbols.
egrep -v "^(0x00000000 . )?_swix?$" < syms.C_Entries > syms.A_Entries
rom_link_RISC_OSLib: ${ROM_OBJS} rom_link_Entries
${XTENT} syms.Entries kernel.s.k_entries clib.s.cl_entries rlib.s.rl_entries
print rlib.swi { >> syms.Entries }
${LD} ${LDFLAGS} -o linked.RISC_OSLib ${ROM_OBJS} \
-symdefs syms.C_Entries \
-symdefs syms.A_Entries \
-symdefs syms.Entries \
-symbols syms.${TARGET} \
-bin -base ${ADDRESS} \
-map > map.${TARGET}
rom_link_CLib: ${CLIB_ROM_OBJS}
${LD} -o linked.CLib ${CLIB_ROM_OBJS} \
rom_link_CLib: ${CLIB_ROM_OBJS} rom_link_Entries
${XTENT} syms.Entries kernel.s.k_entries clib.s.cl_entries
print rlib.swi { >> syms.Entries }
${LD} ${LDFLAGS} -o linked.CLib ${CLIB_ROM_OBJS} \
-symdefs syms.C_Entries \
-symdefs syms.A_Entries \
-symdefs syms.Entries \
-symbols syms.${TARGET} \
-bin -base ${ADDRESS} \
-map > map.${TARGET}
......@@ -479,27 +504,10 @@ rom_link_CLib: ${CLIB_ROM_OBJS}
rom_link: rom_link_${TARGET}
${CP} linked.${TARGET} ${LINKDIR}.${TARGET} ${CPFLAGS}
|
if "${TARGET}"="RISC_OSLib" Then Set ExtraLibs$xtentries rlib.s.rl_entries Else Unset ExtraLibs$xtentries
@echo xtentries syms.Entries kernel.s.k_entries clib.s.cl_entries <ExtraLibs$xtentries>
@do xtentries syms.Entries kernel.s.k_entries clib.s.cl_entries <ExtraLibs$xtentries>
unset ExtraLibs$xtentries
print rlib.swi { >> syms.Entries }
xtentries syms.C_Entries kernel.s.k_entries clib.s.cl_entries
print rlib.swi { >> syms.C_Entries }
| C_Entries *currently* only adds _swi/_swix to RO2 symbols.
egrep -v "^_swix?$" < syms.C_Entries > syms.A_Entries
|
symgen syms.Entries syms.${TARGET} s.abssym
symgen syms.C_Entries syms.${TARGET} s.c_abssym
symgen syms.A_Entries syms.${TARGET} s.a_abssym
|
${OBJASM} ${AFLAGS} -from s.abssym -to o.abssym
${OBJASM} ${AFLAGS} -from s.c_abssym -to o.c_abssym
${OBJASM} ${AFLAGS} -from s.a_abssym -to o.a_abssym
${CP} syms.Entries ${ABSSYM} ${CPFLAGS}
${CP} syms.C_Entries ${C_ABSSYM} ${CPFLAGS}
${CP} syms.A_Entries ${A_ABSSYM} ${CPFLAGS}
|
${CP} o.abssym ${ABSSYM} ${CPFLAGS}
${CP} o.c_abssym ${C_ABSSYM} ${CPFLAGS}
${CP} o.a_abssym ${A_ABSSYM} ${CPFLAGS}
@echo ${COMPONENT}: rom_link complete
#
......@@ -531,7 +539,7 @@ lib.romastubs: rlib.s.rl_stub_a
# Non-exported libraries:
lib.clib: ${CLIB_MOD_OBJS}
${LD} -o $@ -module ${CLIB_MOD_OBJS}
${LD} ${LDFLAGS} -o $@ -module ${CLIB_MOD_OBJS}
# Derived headers:
derived.swis: s.makehswis h.swisheader s.swioptions
......
......@@ -9,12 +9,12 @@
GBLS Module_ApplicationDate2
GBLS Module_ApplicationDate4
GBLS Module_HelpVersion
Module_MajorVersion SETS "5.15"
Module_Version SETA 515
Module_MajorVersion SETS "5.16"
Module_Version SETA 516
Module_MinorVersion SETS ""
Module_Date SETS "02 Oct 2000"
Module_ApplicationDate2 SETS "02-Oct-00"
Module_ApplicationDate4 SETS "02-Oct-2000"
Module_FullVersion SETS "5.15"
Module_HelpVersion SETS "5.15 (02 Oct 2000)"
Module_FullVersion SETS "5.16"
Module_HelpVersion SETS "5.16 (02 Oct 2000)"
END
/* (5.15)
/* (5.16)
*
* This file is automatically maintained by srccommit, do not edit manually.
*
*/
#define Module_MajorVersion_CMHG 5.15
#define Module_MajorVersion_CMHG 5.16
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 02 Oct 2000
#define Module_MajorVersion "5.15"
#define Module_Version 515
#define Module_MajorVersion "5.16"
#define Module_Version 516
#define Module_MinorVersion ""
#define Module_Date "02 Oct 2000"
#define Module_ApplicationDate2 "02-Oct-00"
#define Module_ApplicationDate4 "02-Oct-2000"
#define Module_FullVersion "5.15"
#define Module_HelpVersion "5.15 (02 Oct 2000)"
#define Module_FullVersion "5.16"
#define Module_HelpVersion "5.16 (02 Oct 2000)"
......@@ -409,44 +409,33 @@ char *getenv(const char *name)
_kernel_swi_regs r, rout;
_kernel_oserror *e;
/* Make sure we have an initial buffer of 256 */
if (_getenv_value == NULL) {
_getenv_value = malloc(256);
if (_getenv_value == NULL) return NULL;
_getenv_size = 256;
}
/* Try to read into the current buffer */
/* Whilst we keep getting buffer overflow errors, try to extend the buffer
* a bit and try again. Note that you CANNOT rely on OS_ReadVarVal returning
* (NOT length) in R2 since this doesn't work for number or macro variables.
* It doesn't work.
*/
r.r[0] = (int) name;
r.r[1] = (int) _getenv_value;
r.r[2] = _getenv_size - 1;
r.r[3] = 0;
r.r[4] = 3;
if ((e = _kernel_swi(OS_ReadVarVal, &r, &rout)) != NULL)
{
/* If there was a buffer overflow... */
if (e->errnum != 0x1E4)
return NULL;
/* ...find out how much space is required */
r.r[2] = -1;
_kernel_swi(OS_ReadVarVal, &r, &rout);
if (rout.r[2] >= 0)
return NULL;
/* Try to reallocate the buffer */
free(_getenv_value);
_getenv_value = malloc(-rout.r[2]);
if (_getenv_value == NULL)
return NULL;
/* And read again */
_getenv_size = -rout.r[2];
r.r[1] = (int) _getenv_value;
r.r[2] = _getenv_size - 1;
if (_kernel_swi(OS_ReadVarVal, &r, &rout) != NULL)
return NULL;
}
do {
/* Try to read into the current buffer */
r.r[1] = (int) _getenv_value;
r.r[2] = _getenv_size - 1;
if ((e = _kernel_swi(OS_ReadVarVal, &r, &rout)) != NULL)
{
/* If there was a buffer overflow... */
if (e->errnum != 0x1E4)
return NULL;
/* Try to reallocate the buffer */
free(_getenv_value);
_getenv_value = malloc(_getenv_size += 256);
if (_getenv_value == NULL) {
_getenv_size = 0;
return NULL;
}
}
} while (e);
/* Terminate the value */
_getenv_value[rout.r[2]] = '\0';
......
_Shared_Lib_Module_SWI_Code
0x00000000 A _Shared_Lib_Module_SWI_Code
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment