From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Lance Taylor To: tranle@intellicorp.com Cc: gas2@cygnus.com Subject: Re: problem with ld (i386-coff) leaving holes in the Date: Wed, 10 Aug 1994 10:03:00 -0000 Message-id: <199408101703.NAA05133@sanguine.cygnus.com> References: <199408092045.AA17786@bridge2.NSD.3Com.COM> X-SW-Source: 1994/msg00064.html Date: Tue, 9 Aug 94 13:43:16 PDT From: Minh Tran-Le Maybe the function styp_to_sec_flags should not set the default section flags to SEC_LOAD|SEC_ALLOC. I'm scared to make that change. I'm sure it would break on some system in a way that would be difficult to fix. How about the following (untested) patch instead? After installing this, do ``make headers'' in the bfd object directory to rebuild libcoff.h. Ian *** coffcode.h.~16~ Mon Aug 8 10:48:52 1994 --- coffcode.h Wed Aug 10 12:07:20 1994 *************** sec_to_styp_flags (sec_name, sec_flags) *** 405,413 **** * in sec_to_styp_flags(). */ static flagword ! styp_to_sec_flags (abfd, hdr) ! bfd * abfd; PTR hdr; { struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; long styp_flags = internal_s->s_flags; --- 405,414 ---- * in sec_to_styp_flags(). */ static flagword ! styp_to_sec_flags (abfd, hdr, name) ! bfd *abfd; PTR hdr; + const char *name; { struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; long styp_flags = internal_s->s_flags; *************** styp_to_sec_flags (abfd, hdr) *** 457,462 **** --- 458,511 ---- sec_flags |= SEC_DEBUGGING; #endif } + else if (strcmp (name, _TEXT) == 0) + { + if (sec_flags & SEC_NEVER_LOAD) + sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY; + else + sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC; + } + else if (strcmp (name, _DATA) == 0 + #ifdef TWO_DATA_SECS + || strcmp (name, ".data2") == 0 + #endif + ) + { + if (sec_flags & SEC_NEVER_LOAD) + sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY; + else + sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC; + } + else if (strcmp (name, _BSS) == 0) + { + #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY + if (sec_flags & SEC_NEVER_LOAD) + sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY; + else + #endif + sec_flags |= SEC_ALLOC; + } + else if (strcmp (name, ".debug") == 0 + #ifdef _COMMENT + || strcmp (name, _COMMENT) == 0 + #endif + || strcmp (name, ".stab") == 0 + || strcmp (name, ".stabstr") == 0) + { + #ifdef COFF_PAGE_SIZE + sec_flags |= SEC_DEBUGGING; + #endif + } + #ifdef _LIB + else if (strcmp (name, _LIB) == 0) + ; + #endif + #ifdef _LIT + else if (strcmp (name, _LIT) == 0) + { + sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY; + } + #endif else { sec_flags |= SEC_ALLOC | SEC_LOAD; *************** dependent COFF routines: *** 585,591 **** . PTR internal_aouthdr)); . flagword (*_bfd_styp_to_sec_flags_hook) PARAMS (( . bfd *abfd, ! . PTR internal_scnhdr)); . asection *(*_bfd_make_section_hook) PARAMS (( . bfd *abfd, . char *name)); --- 634,641 ---- . PTR internal_aouthdr)); . flagword (*_bfd_styp_to_sec_flags_hook) PARAMS (( . bfd *abfd, ! . PTR internal_scnhdr, ! . const char *name)); . asection *(*_bfd_make_section_hook) PARAMS (( . bfd *abfd, . char *name)); *************** dependent COFF routines: *** 671,678 **** .#define bfd_coff_mkobject_hook(abfd, filehdr, aouthdr)\ . ((coff_backend_info (abfd)->_bfd_coff_mkobject_hook) (abfd, filehdr, aouthdr)) . ! .#define bfd_coff_styp_to_sec_flags_hook(abfd, scnhdr)\ ! . ((coff_backend_info (abfd)->_bfd_styp_to_sec_flags_hook) (abfd, scnhdr)) . .#define bfd_coff_make_section_hook(abfd, name)\ . ((coff_backend_info (abfd)->_bfd_make_section_hook) (abfd, name)) --- 721,728 ---- .#define bfd_coff_mkobject_hook(abfd, filehdr, aouthdr)\ . ((coff_backend_info (abfd)->_bfd_coff_mkobject_hook) (abfd, filehdr, aouthdr)) . ! .#define bfd_coff_styp_to_sec_flags_hook(abfd, scnhdr, name)\ ! . ((coff_backend_info (abfd)->_bfd_styp_to_sec_flags_hook) (abfd, scnhdr, name)) . .#define bfd_coff_make_section_hook(abfd, name)\ . ((coff_backend_info (abfd)->_bfd_make_section_hook) (abfd, name)) Index: coffgen.c =================================================================== RCS file: /rel/cvsfiles/devo/bfd/coffgen.c,v retrieving revision 1.34 diff -p -r1.34 coffgen.c *** coffgen.c 1994/06/21 16:46:51 1.34 --- coffgen.c 1994/08/10 17:03:06 *************** make_a_section_from_file (abfd, hdr, tar *** 99,105 **** return_section->lineno_count = hdr->s_nlnno; return_section->userdata = NULL; return_section->next = (asection *) NULL; ! return_section->flags = bfd_coff_styp_to_sec_flags_hook (abfd, hdr); return_section->target_index = target_index; --- 99,105 ---- return_section->lineno_count = hdr->s_nlnno; return_section->userdata = NULL; return_section->next = (asection *) NULL; ! return_section->flags = bfd_coff_styp_to_sec_flags_hook (abfd, hdr, name); return_section->target_index = target_index;