How do a change the name of a function or delete a function symbol table entry?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I am more familiar with the RTL backend, and I am less familiar with the
earlier parts of the compiler.

I'm trying to 'fix' the target_clone support for the PowerPC, while leaving the
support for the x86 to be the same as it currently is (possibily allowing them
to change the behavior if they would prefer).

The target clone support allows you to version a function so that it will call
the appropriate function with different -mcpu= options based on the attributes
of the machine when you are running on it.

So for example:

	__attribute__((__target_clone__("cpu=power9,default")))
	long do_mod (long a, long b)
	{
	  return a % b;
	}

would generate 4 function symbol nodes:

    1)	The original symbol node will be the function with the target attribute
	"default" enabled, and has the original name, "do_mod".  Assuming the
	defaults are not -mcpu=power9, on the PowerPC, this will generate a
	divide, multiply, and subtract instructions.

    2)	A new function symbol node that has the target attribute "cpu=power9"
	enabled, and it has a name of the form "do_mod.cpu_power9.0".  This
	function will generate the new ISA 3.0 "MODSD" modulus instruction.

    3)	A resolver function that returns void *, and when it is invoked, it
	returns either "do_mod" or "do_mod.cpu_power9.0" depending on the
	attributes of the current machine.

    4)	The ifunc function with the name "do_mode.ifunc" that is linked to the
	resolver function, and the linker will set things up so that the shared
	library loader will call "do_mod.resolver" to discover the address to
	use for the function do_mod.  Note, this function has to be external,
	and if "do_mod" was declared static, a different name is used to make
	it unique (in looking at the asm code, I suspect this is a problem,
	becuase name is "mod_func._GLOBAL___mod_func_add.ifunc" and not
	something based on the filename).

If "do_mod" is external, any other call to "do_mod" outside of the current file
being compiled will call the default function, and not call the target specific
function.  I think the external name that is linked to the resolver function
should be "do_mod" and the default function should be something like
"do_mod.default.2".

After we've created the clones, and the resolver function, I would like to
rename the original function from "do_mod" to "do_mod.default", and make it
non-public.  I would also change the ifunc resolver to not have the ".ifunc"
suffix.  However, changing the decl assembler name and other things I've tried,
either does not change anything, or I get errors in the cgraph functions saying
unknown name.

Alternatively, I can create an other clone for the default function, and I
would like to either replace the the current node with the .ifunc node (and
when I create the .ifunc node, I would create it without the name).

A third method would be to delete the symbol node with the target_clone
attribute.

Is there a simple method to accomplish any of these changes?

Thanks in advance.

-- 
Michael Meissner, IBM
IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA
email: meissner@xxxxxxxxxxxxxxxxxx, phone: +1 (978) 899-4797




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux