Sponsored Content
Full Discussion: LD linker define symbol
Top Forums UNIX for Advanced & Expert Users LD linker define symbol Post 302181570 by lzwierko on Thursday 3rd of April 2008 10:47:27 AM
Old 04-03-2008
LD linker define symbol

Hi, I want to define a symbol in my code as:

extern int Address;

and then I'd like to define the symbol value in linker (ld) script file, so each time I change the hardware, I don't need to redefine the value in code, just use different linker script. I've gone through ld reference and didn't find any clue how to do it...
Appreciate any help,

regards

LZwierko
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Linker (ld)

hai I have installed Linux 7.0 on my system and i have an doubt the linker i ran simple hello.c program with gcc compiler gcc -c hello.c i want linker to produce the output so i put on the command line as ld first.o -lc but it is not running ver properly but there is an... (1 Reply)
Discussion started by: rajashekaran
1 Replies

2. Programming

Linker error when using vector's

using SUN C++ I have a problem when I do a push_back on a vector. The linker gives me a undefined symbol error on __cxa_end_catch. Any ideas, is there a library to include? Thanks Chris (1 Reply)
Discussion started by: CDurkin
1 Replies

3. HP-UX

dynamic linker error

Hi All Could anyone help in giving a little background to the following runtime error. /usr/lib/pa20_64/dld.sl: Mmap failed due to errno: 13. Seen when executing a 64-bit ELF executable. Thanks Ed (3 Replies)
Discussion started by: C3000
3 Replies

4. Linux

G++ Linker Error

Hi All, I m new to this group. I m facing one problem during my linking of CPP code at Linux env. after compliation i m getting error "undefined reference to ....." Please anyone help me to resolve this error. Regards, ASR make: Leaving directory /fwk' echo g++ -o server ... (1 Reply)
Discussion started by: ASRRAJ
1 Replies

5. HP-UX

Hp-ux linker option -c

Hi, The necessary symbols in a shared library can be exported to the application using linker option --version-script in Linux. The same can be done in Hp-ux using linker option +e. This can also be done by listing all the global symbols with +e in a file with linker option ld -c filename in... (0 Replies)
Discussion started by: roopa_v
0 Replies

6. Programming

GCC: Choose my own linker

Hi, I do not use the default linker, and instead us another one and pass this argument -Wl,--dynamic-linker=<path to linker> to gcc when compiling. However, what happens if the linker is not under /lib and /lib64 and I am not able to create a symlink to the linker in /lib or /lib64 due to no... (2 Replies)
Discussion started by: Shompis
2 Replies

7. Solaris

/usr/lib/passwdutil.so.1: symbol __nsl_fgetspent_r: referenced symbol not found

deleteing post (0 Replies)
Discussion started by: dshakey
0 Replies

8. Programming

gcc linker address

Hai, I have two (Pgm1.c and Pgm2.c) simple programs, which is compiled using gcc. Now we have two exe's (Pgm1 and Pgm2). When i executed the nm Pgm1 and nm Pgm2, in the listed symbols the address of main is same for both programs (08048344 T main) at run time also. Doubt: 1) What is this... (3 Replies)
Discussion started by: rajamohan
3 Replies

9. Programming

AIX linker oddities...what is going on?

I've tried to figure out what the linker is smoking in AIX to no avail...so I'm trying to find a little information to see why it's being inconsistent. I have the following code in a shared library, it doesn't do anything useful, it's just there to exercise functions in a few system libraries: ... (11 Replies)
Discussion started by: DreamWarrior
11 Replies

10. Solaris

Runtime Linker Problems ld.so.1

Hello all, I am releatively new to Solaris and I am the System administrator for my branch at the FAA. This is the first time I can say I have really messed something up thankfully. My issue came up after installing and uninstalling Oracle Secure Backup which i felt I needed to do a clean... (7 Replies)
Discussion started by: jbirkes
7 Replies
STAB(5) 						      BSD File Formats Manual							   STAB(5)

NAME
stab -- symbol table types SYNOPSIS
#include <stab.h> DESCRIPTION
The file <stab.h> defines some of the symbol table n_type field values for a.out files. These are the types for permanent symbols (i.e., not local labels, etc.) used by the old debugger sdb and the Berkeley Pascal compiler pc(1). Symbol table entries can be produced by the .stabs assembler directive. This allows one to specify a double-quote delimited name, a symbol type, one char and one short of information about the symbol, and an unsigned long (usually an address). To avoid having to produce an explicit label for the address field, the .stabd direc- tive can be used to implicitly address the current location. If no name is needed, symbol table entries can be generated using the .stabn directive. The loader promises to preserve the order of symbol table entries produced by .stab directives. As described in a.out(5), an element of the symbol table consists of the following structure: /* * Format of a symbol table entry. */ struct nlist { union { const char *n_name; /* for use when in-core */ long n_strx; /* index into file string table */ } n_un; unsigned char n_type; /* type flag */ char n_other; /* unused */ short n_desc; /* see struct desc, below */ unsigned n_value; /* address or offset or line */ }; The low bits of the n_type field are used to place a symbol into at most one segment, according to the following masks, defined in <a.out.h>. A symbol can be in none of these segments by having none of these segment bits set. /* * Simple values for n_type. */ #define N_UNDF 0x0 /* undefined */ #define N_ABS 0x2 /* absolute */ #define N_TEXT 0x4 /* text */ #define N_DATA 0x6 /* data */ #define N_BSS 0x8 /* bss */ #define N_EXT 01 /* external bit, or'ed in */ The n_value field of a symbol is relocated by the linker, ld(1) as an address within the appropriate segment. N_value fields of symbols not in any segment are unchanged by the linker. In addition, the linker will discard certain symbols, according to rules of its own, unless the n_type field has one of the following bits set: /* * Other permanent symbol table entries have some of the N_STAB bits set. * These are given in <stab.h> */ #define N_STAB 0xe0 /* if any of these bits set, don't discard */ This allows up to 112 (7 * 16) symbol types, split between the various segments. Some of these have already been claimed. The old symbolic debugger, sdb, uses the following n_type values: #define N_GSYM 0x20 /* global symbol: name,,0,type,0 */ #define N_FNAME 0x22 /* procedure name (f77 kludge): name,,0 */ #define N_FUN 0x24 /* procedure: name,,0,linenumber,address */ #define N_STSYM 0x26 /* static symbol: name,,0,type,address */ #define N_LCSYM 0x28 /* .lcomm symbol: name,,0,type,address */ #define N_RSYM 0x40 /* register sym: name,,0,type,register */ #define N_SLINE 0x44 /* src line: 0,,0,linenumber,address */ #define N_SSYM 0x60 /* structure elt: name,,0,type,struct_offset */ #define N_SO 0x64 /* source file name: name,,0,0,address */ #define N_LSYM 0x80 /* local sym: name,,0,type,offset */ #define N_SOL 0x84 /* #included file name: name,,0,0,address */ #define N_PSYM 0xa0 /* parameter: name,,0,type,offset */ #define N_ENTRY 0xa4 /* alternate entry: name,linenumber,address */ #define N_LBRAC 0xc0 /* left bracket: 0,,0,nesting level,address */ #define N_RBRAC 0xe0 /* right bracket: 0,,0,nesting level,address */ #define N_BCOMM 0xe2 /* begin common: name,, */ #define N_ECOMM 0xe4 /* end common: name,, */ #define N_ECOML 0xe8 /* end common (local name): ,,address */ #define N_LENG 0xfe /* second stab entry with length information */ where the comments give sdb conventional use for .stab s and the n_name, n_other, n_desc, and n_value fields of the given n_type. Sdb uses the n_desc field to hold a type specifier in the form used by the Portable C Compiler, cc(1); see the header file pcc.h for details on the format of these type values. The Berkeley Pascal compiler, pc(1), uses the following n_type value: #define N_PC 0x30 /* global pascal symbol: name,,0,subtype,line */ and uses the following subtypes to do type checking across separately compiled files: 1 source file name 2 included file name 3 global label 4 global constant 5 global type 6 global variable 7 global function 8 global procedure 9 external function 10 external procedure 11 library variable 12 library routine SEE ALSO
as(1), ld(1), a.out(5) HISTORY
The stab file appeared in 4.0BSD. BUGS
More basic types are needed. BSD
June 10, 2010 BSD
All times are GMT -4. The time now is 04:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy