コード例 #1
0
ファイル: fixes.c プロジェクト: OpenDarwin-CVS/SEDarwin
/*
 * fix_new() creates a fixS in obstack 'notes'.
 */
void
fix_new(
fragS	*frag,		/* which frag? */
int	where,		/* where in that frag? */
int	size,		/* 1, 2 or 4 bytes */
symbolS *add_symbol,	/* X_add_symbol */
symbolS *sub_symbol,	/* X_subtract_symbol */
long    offset,		/* X_add_number */
int	pcrel,		/* TRUE if PC-relative relocation */
int	pcrel_reloc,	/* TRUE if must have relocation entry */
int	r_type)		/* relocation type */
{
    struct fix *fixP;

	fixP = (struct fix *)obstack_alloc(&notes, sizeof(struct fix));

	fixP->fx_frag	     = frag;
	fixP->fx_where       = where;
	fixP->fx_size	     = size;
	fixP->fx_addsy       = add_symbol;
	fixP->fx_subsy       = sub_symbol;
	fixP->fx_offset      = offset;
	fixP->fx_pcrel       = pcrel;
	fixP->fx_pcrel_reloc = pcrel_reloc;
	fixP->fx_r_type      = r_type;
	as_file_and_line (&fixP->file, &fixP->line);

	fixP->fx_next              = frchain_now->frch_fix_root;
	frchain_now->frch_fix_root = fixP;
}
コード例 #2
0
ファイル: fixes.c プロジェクト: DJHartley/iphone-dev
/*
 * fix_new() creates a fixS in obstack 'notes'.
 */
fixS *
fix_new(
fragS	*frag,		/* which frag? */
int	where,		/* where in that frag? */
int	size,		/* 1, 2, 4 or 8 bytes */
symbolS *add_symbol,	/* X_add_symbol */
symbolS *sub_symbol,	/* X_subtract_symbol */
	signed_target_addr_t
	offset,		/* X_add_number */
int	pcrel,		/* TRUE if PC-relative relocation */
int	pcrel_reloc,	/* TRUE if must have relocation entry */
int	r_type)		/* relocation type */
{
    struct fix *fixP;

	fixP = (struct fix *)obstack_alloc(&notes, sizeof(struct fix));

	fixP->fx_frag	     = frag;
	fixP->fx_where       = where;
	fixP->fx_size	     = size;
	fixP->fx_addsy       = add_symbol;
	fixP->fx_subsy       = sub_symbol;
	fixP->fx_offset      = offset;
	fixP->fx_pcrel       = pcrel;
	fixP->fx_pcrel_reloc = pcrel_reloc;
	fixP->fx_r_type      = r_type;
#if defined(I386) && defined(ARCH64)
	if(fixP->fx_r_type == X86_64_RELOC_SIGNED){
		switch(offset){
			case -1:
				fixP->fx_r_type = X86_64_RELOC_SIGNED_1;
				break;
			case -2:
				fixP->fx_r_type = X86_64_RELOC_SIGNED_2;
				break;
			case -4:
				fixP->fx_r_type = X86_64_RELOC_SIGNED_4;
				break;
			default:
				break;
		}
	}
	if(fixP->fx_r_type == X86_64_RELOC_GOT ||
	   fixP->fx_r_type == X86_64_RELOC_GOT_LOAD){
		/*
		 * GOT and GOT_LOAD relocs are always PC-relative and
		 * should not be converted to non-PC-relative addressing
		 * later.
		 */
		fixP->fx_pcrel = TRUE;
		fixP->fx_pcrel_reloc = TRUE;
	}
	/* We don't need this for non-local symbols, but it doesn't hurt. */
	fixP->fx_localsy = symbol_new("L0\002", N_SECT, frchain_now->frch_nsect,
	                              0, where, frag);
	symbol_assign_index(fixP->fx_localsy);
#endif
	as_file_and_line (&fixP->file, &fixP->line);

	fixP->fx_next              = frchain_now->frch_fix_root;
	frchain_now->frch_fix_root = fixP;
	
	return fixP;
}