Making a symbol dynamic in executable

Zack Weinberg zackw@Stanford.EDU
Fri Feb 23 21:12:00 GMT 2001


On Fri, Feb 23, 2001 at 06:36:10PM -0800, H . J . Lu wrote:
> On Fri, Feb 23, 2001 at 06:16:01PM -0800, Zack Weinberg wrote:
> > 
> > That implies, to me, that there might be a way to force just one
> > symbol into the dynamic symbol table.  I know very little about this.
> > Worst case (in ELF), couldn't we bodge an entry into .dynsym by hand?
> > 
> 
> Funny you asked. The short answer is no. But we did get a request to add
> STV_EXPORT to the ELF visibility in gABI.

Heh.  I don't think you appreciated what I meant by "bodge an entry
into .dynsym by hand."  This is what I meant:

	.globl __frame_objects
	.data
	.type __frame_objects,@object
	.size __frame_objects,4
__frame_objects:
	.long 0

	.section .dynstr
.Lname:
	.asciz "__frame_objects"

	.section .dynsym
	.long .Lname-.dynstr		# st_name
	.long __frame_objects-.data	# st_value
	.long 4				# st_size
	.byte (1 << 4) + 1		# st_info: (STB_GLOBAL, STT_OBJECT)
	.byte 0				# st_other
	.word 2				# st_shndx (assumed data==2)
	
This generates an object file with an apparently correct dynamic
symbol table, but the linker strips it when you try to put it into an
executable.  Oh well.

zw



More information about the Binutils mailing list