http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51916
Iain Sandoe <iains at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2012-01-21 Ever Confirmed|0 |1 --- Comment #8 from Iain Sandoe <iains at gcc dot gnu.org> 2012-01-21 10:04:58 UTC --- (In reply to comment #7) Thanks for the debugging Patrick. > Tracing a bit more, I see that simple_object_mach_o_match() ends with this: > *errmsg = "Mach-O file found but no segment name specified"; > Indeed, lto-wrapper always gives NULL for the segment name. > sobj = simple_object_start_read (fd, file_offset, NULL, &errmsg, &err); > > So, since there is no documentation/specification of the > simple_object_start_read function I cannot say if it is a gcc/lto bug or a > libiberty bug. include/simple_object.h: /* Create an simple_object_read given DESCRIPTOR, an open file descriptor, and OFFSET, an offset within the file. The offset is for use with archives, and should be 0 for an ordinary object file. The descriptor must remain open until done with the returned simple_object_read. SEGMENT_NAME is used on Mach-O and is required on that platform: it means to only look at sections within the segment with that name. It is ignored for other object file formats. On error, this function returns NULL, and sets *ERRMSG to an error string and sets *ERR to an errno value or 0 if there is no relevant errno. */ extern simple_object_read * simple_object_start_read (int descriptor, off_t offset, const char *segment_name, const char **errmsg, int *err); > Finally, there is a problem with lto-wrapper.c > if (!simple_object_find_section (sobj, LTO_SECTION_NAME_PREFIX "." > "opts", > &offset, &length, &errmsg, &err)) > In MacOSX, I don't know the section name for opts (I have __wrapper_index, > __wrapper_sects, and __wrapper_names) but if I add the segment name > "__GNU_LTO" > , the section name is ".gnu.lto_.opts" (not existing in my files). the sections are there (inside the wrapper - if you objdump or hexdump -C the objects you'll see them) and if I apply this hack the link works (the objects are correctly formed as of now): Index: gcc/lto-wrapper.c =================================================================== --- gcc/lto-wrapper.c (revision 183359) +++ gcc/lto-wrapper.c (working copy) @@ -479,7 +479,7 @@ run_gcc (unsigned argc, char *argv[]) fd = open (argv[i], O_RDONLY); if (fd == -1) continue; - sobj = simple_object_start_read (fd, file_offset, NULL, &errmsg, &err); + sobj = simple_object_start_read (fd, file_offset, "__GNU_LTO", &errmsg, &err); if (!sobj) { close (fd); ... so this is a build/config issue - or, alternatively, the segment name can be specified as above since it is ignored for non-mach-o platforms. thanks Iain