Refactor object file source name storage
Teach 'comp_lits' and 'emit_literals' to lookup the source file name through a new 'obj_source' structure. This will allow the source file to be modified before storage in the object file.
This commit is contained in:
parent
5b7c3e51e7
commit
9e807f2434
|
@ -30,6 +30,7 @@
|
||||||
#include "gtmio.h"
|
#include "gtmio.h"
|
||||||
#include "mmemory.h"
|
#include "mmemory.h"
|
||||||
#include "obj_file.h"
|
#include "obj_file.h"
|
||||||
|
#include <obj_source.h>
|
||||||
|
|
||||||
LITREF char gtm_release_name[];
|
LITREF char gtm_release_name[];
|
||||||
LITREF int4 gtm_release_name_len;
|
LITREF int4 gtm_release_name_len;
|
||||||
|
@ -444,8 +445,11 @@ void emit_literals(void)
|
||||||
emit_immed(PADCHARS, padsize);
|
emit_immed(PADCHARS, padsize);
|
||||||
offset += padsize;
|
offset += padsize;
|
||||||
}
|
}
|
||||||
emit_immed(source_file_name, source_name_len);
|
{
|
||||||
offset += source_name_len;
|
struct obj_source s = get_obj_source();
|
||||||
|
emit_immed(s.name, s.len);
|
||||||
|
offset += s.len;
|
||||||
|
}
|
||||||
/* comp_lits aligns the start of routine_name on a NATIVE_WSIZE boundary.*/
|
/* comp_lits aligns the start of routine_name on a NATIVE_WSIZE boundary.*/
|
||||||
padsize = PADLEN(offset, NATIVE_WSIZE);
|
padsize = PADLEN(offset, NATIVE_WSIZE);
|
||||||
if (padsize)
|
if (padsize)
|
||||||
|
|
|
@ -14,10 +14,10 @@
|
||||||
#include <rtnhdr.h>
|
#include <rtnhdr.h>
|
||||||
#include "mdq.h"
|
#include "mdq.h"
|
||||||
#include "stringpool.h"
|
#include "stringpool.h"
|
||||||
|
#include <obj_source.h>
|
||||||
|
|
||||||
GBLREF mliteral literal_chain;
|
GBLREF mliteral literal_chain;
|
||||||
GBLREF spdesc stringpool;
|
GBLREF spdesc stringpool;
|
||||||
GBLREF unsigned short source_name_len;
|
|
||||||
GBLREF mident routine_name;
|
GBLREF mident routine_name;
|
||||||
|
|
||||||
GBLDEF uint4 lits_text_size, lits_mval_size;
|
GBLDEF uint4 lits_text_size, lits_mval_size;
|
||||||
|
@ -34,9 +34,12 @@ void comp_lits(rhdtyp *rhead)
|
||||||
* following the literal text pool and is considered part of that text pool.*/
|
* following the literal text pool and is considered part of that text pool.*/
|
||||||
offset = (stringpool.free - stringpool.base);
|
offset = (stringpool.free - stringpool.base);
|
||||||
offset += PADLEN(offset, NATIVE_WSIZE);
|
offset += PADLEN(offset, NATIVE_WSIZE);
|
||||||
rhead->src_full_name.len = source_name_len;
|
{
|
||||||
|
struct obj_source s = get_obj_source();
|
||||||
|
rhead->src_full_name.len = s.len;
|
||||||
rhead->src_full_name.addr = (char *)offset;
|
rhead->src_full_name.addr = (char *)offset;
|
||||||
offset += source_name_len;
|
offset += s.len;
|
||||||
|
}
|
||||||
offset += PADLEN(offset, NATIVE_WSIZE);
|
offset += PADLEN(offset, NATIVE_WSIZE);
|
||||||
rhead->routine_name.len = routine_name.len;
|
rhead->routine_name.len = routine_name.len;
|
||||||
rhead->routine_name.addr = (char *)offset;
|
rhead->routine_name.addr = (char *)offset;
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include "gtmio.h"
|
#include "gtmio.h"
|
||||||
#include "mmemory.h"
|
#include "mmemory.h"
|
||||||
#include "obj_file.h"
|
#include "obj_file.h"
|
||||||
|
#include <obj_source.h>
|
||||||
|
|
||||||
GBLREF char object_file_name[];
|
GBLREF char object_file_name[];
|
||||||
GBLREF short object_name_len;
|
GBLREF short object_name_len;
|
||||||
|
@ -38,8 +39,6 @@ GBLREF boolean_t run_time;
|
||||||
GBLREF int4 lits_text_size, lits_mval_size;
|
GBLREF int4 lits_text_size, lits_mval_size;
|
||||||
GBLREF unsigned char *runtime_base;
|
GBLREF unsigned char *runtime_base;
|
||||||
GBLREF mliteral literal_chain;
|
GBLREF mliteral literal_chain;
|
||||||
GBLREF char source_file_name[];
|
|
||||||
GBLREF unsigned short source_name_len;
|
|
||||||
GBLREF mident routine_name;
|
GBLREF mident routine_name;
|
||||||
GBLREF spdesc stringpool;
|
GBLREF spdesc stringpool;
|
||||||
GBLREF int4 linkage_size;
|
GBLREF int4 linkage_size;
|
||||||
|
@ -381,8 +380,11 @@ void emit_literals(void)
|
||||||
emit_immed(PADCHARS, padsize);
|
emit_immed(PADCHARS, padsize);
|
||||||
offset += padsize;
|
offset += padsize;
|
||||||
}
|
}
|
||||||
emit_immed(source_file_name, source_name_len);
|
{
|
||||||
offset += source_name_len;
|
struct obj_source s = get_obj_source();
|
||||||
|
emit_immed(s.name, s.len);
|
||||||
|
offset += s.len;
|
||||||
|
}
|
||||||
padsize = (uint4)(PADLEN(offset, NATIVE_WSIZE)); /* comp_lits aligns the start of routine_name on NATIVE_WSIZE boundary.*/
|
padsize = (uint4)(PADLEN(offset, NATIVE_WSIZE)); /* comp_lits aligns the start of routine_name on NATIVE_WSIZE boundary.*/
|
||||||
if (padsize)
|
if (padsize)
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
#include "mdef.h"
|
||||||
|
|
||||||
|
#include "obj_source.h"
|
||||||
|
|
||||||
|
GBLREF char source_file_name[];
|
||||||
|
GBLREF unsigned short source_name_len;
|
||||||
|
|
||||||
|
struct obj_source get_obj_source(void)
|
||||||
|
{
|
||||||
|
struct obj_source sn = {source_file_name, source_name_len};
|
||||||
|
return sn;
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
#ifndef __OBJ_SOURCE_H__
|
||||||
|
#define __OBJ_SOURCE_H__
|
||||||
|
|
||||||
|
struct obj_source
|
||||||
|
{
|
||||||
|
char* name;
|
||||||
|
unsigned short len;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct obj_source get_obj_source(void);
|
||||||
|
|
||||||
|
#endif
|
|
@ -14,10 +14,10 @@
|
||||||
#include "rtnhdr.h"
|
#include "rtnhdr.h"
|
||||||
#include "mdq.h"
|
#include "mdq.h"
|
||||||
#include "stringpool.h"
|
#include "stringpool.h"
|
||||||
|
#include <obj_source.h>
|
||||||
|
|
||||||
GBLREF mliteral literal_chain;
|
GBLREF mliteral literal_chain;
|
||||||
GBLREF spdesc stringpool;
|
GBLREF spdesc stringpool;
|
||||||
GBLREF unsigned short source_name_len;
|
|
||||||
GBLREF mident routine_name;
|
GBLREF mident routine_name;
|
||||||
|
|
||||||
GBLDEF uint4 lits_size, lit_addrs;
|
GBLDEF uint4 lits_size, lit_addrs;
|
||||||
|
@ -31,9 +31,12 @@ rhdtyp *rhead;
|
||||||
|
|
||||||
offset = stringpool.free - stringpool.base;
|
offset = stringpool.free - stringpool.base;
|
||||||
offset += PADLEN(offset, NATIVE_WSIZE);
|
offset += PADLEN(offset, NATIVE_WSIZE);
|
||||||
rhead->src_full_name.len = source_name_len;
|
{
|
||||||
|
struct obj_source s = get_obj_source();
|
||||||
|
rhead->src_full_name.len = s.len;
|
||||||
rhead->src_full_name.addr = (char *)offset;
|
rhead->src_full_name.addr = (char *)offset;
|
||||||
offset += source_name_len;
|
offset += s.len;
|
||||||
|
}
|
||||||
offset += PADLEN(offset, NATIVE_WSIZE);
|
offset += PADLEN(offset, NATIVE_WSIZE);
|
||||||
rhead->routine_name.len = routine_name.len;
|
rhead->routine_name.len = routine_name.len;
|
||||||
rhead->routine_name.addr = (char *)offset;
|
rhead->routine_name.addr = (char *)offset;
|
||||||
|
|
Loading…
Reference in New Issue