File: zlmov_lnames.c

package info (click to toggle)
fis-gtm 6.2-000-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 30,784 kB
  • ctags: 42,554
  • sloc: ansic: 358,483; asm: 4,847; csh: 4,574; sh: 2,261; awk: 200; makefile: 86; sed: 13
file content (57 lines) | stat: -rw-r--r-- 2,122 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/****************************************************************
 *								*
 *	Copyright 2001, 2014 Fidelity Information Services, Inc	*
 *								*
 *	This source code contains the intellectual property	*
 *	of its copyright holder(s), and is made available	*
 *	under a license.  If you do not know the terms of	*
 *	the license, please stop and do not read further.	*
 *								*
 ****************************************************************/

#include "mdef.h"
#include "gtm_string.h"
#include <rtnhdr.h>

#ifdef USHBIN_SUPPORTED
/* Routine to copy label names out of a shared object's literal text pool for a version of an object
 * about to be released to allow label text to still be available for other routines who have links to
 * the label table which has pointers to these label names. The label names are copied into malloc'd
 * storage for the duration of that routine's life in this process.
 *
 * Parameter:
 *
 *   - hdr - Routine header address whose label table needs to be saved.
 *
 * Future change (GTM-8144) would eliminate the need for this.
 */
void zlmov_lnames(rhdtyp *hdr)
{
	lab_tabent	*lab_ent, *lab_bot, *lab_top;
	uint4		size;
	char		*lab_ptr;

	lab_bot = hdr->labtab_adr;
	lab_top = hdr->labtab_adr + hdr->labtab_len;
	size = 0;
	assert((NULL != lab_bot) && (0 == lab_bot->lab_name.len)); /* The first label is null label */
	/* Compute size of label names */
	for (lab_ent = lab_bot + 1; lab_ent < lab_top; lab_ent++)
	{
		assert((lab_ent->lab_name.addr >= (char *)hdr->literal_text_adr)
		       && (lab_ent->lab_name.addr < (char *)(hdr->literal_text_adr + hdr->literal_text_len)));
		size += lab_ent->lab_name.len;
	}
	lab_ptr = (char *)malloc(size);
	/* Store address of malloc'd label text block in the routine header so we can find it to release it on an unlink-all
	 * (ZGOTO 0:entryref).
	 */
	hdr->lbltext_ptr = (unsigned char *)lab_ptr;
	for (lab_ent = lab_bot + 1; lab_ent < lab_top; lab_ent++)
	{
		memcpy(lab_ptr, lab_ent->lab_name.addr, lab_ent->lab_name.len);
		lab_ent->lab_name.addr = lab_ptr;
		lab_ptr += lab_ent->lab_name.len;
	}
}
#endif /* USHBIN_SUPPORTED */