https://sourceware.org/bugzilla/show_bug.cgi?id=25677
Bug ID: 25677 Summary: Changes to --*magic options for pdp11-aout target Product: binutils Version: 2.35 (HEAD) Status: UNCONFIRMED Severity: enhancement Priority: P2 Component: ld Assignee: unassigned at sourceware dot org Reporter: casner at acm dot org Target Milestone: --- Target: pdp11-aout Created attachment 12378 --> https://sourceware.org/bugzilla/attachment.cgi?id=12378&action=edit Proposed enhancement This enhancement consists of two changes related to the ld magic number options. First, the default format for the pdp11-aout target should be --omagic rather than --nmagic to be consistent with the behavior of the ld programs both in Unix v6 at the beginning of Unix on the PDP11 and in 2.11 BSD at its end. That format does not page-align the .data section and generates magic number 0407 which indicates to the runtime system that the .text section should not be read-only. I've changed the default only for the pdp11 emulation. Second, I have added a new option --imagic to generate output with magic number 0411 (defined as IMAGIC in Unix v6 ld.c) that puts both the .text and .data sections starting at address 0 for loading into the separate instruction and data address spaces of larger PDP11 models. For ld on Unix v6 this format was selected with option -i, but that option already has another meaning in binutils ld. In 2.11 BSD the option -z was added as a synonym for -i, so within the pdp11 emulation I also implemented that option as a synonym for --imagic. These changes affect only the pdp11 emulation and they are implemented all within an expansion of the customization files for the pdp11 emulation except for two one-line changes in the common code as explained below. The expansion of the pdp11 customization consists of adding a pdp11.em file containing _before_parse() to adjust the default config settings consistent with --omagic. It also contains functions _add_options(), _list_options() and _handle_option() to implement the additional options including printing pdp11-specific help for all of the --*magic options. I also needed a new _get_script() function that compiles-in a sixth linker script where the .data section starts at address 0. Since genscripts does not produce such a script, when compiling-in the scripts I reuse the script that aligns the data to a page boundary but edit it to set address 0 instead. Related to this, I observe that the code in the adjust_*_magic() functions in bfd/aoutx.h and bfd/pdp11.c that sets the VMA for data is not effective because the alignment directive in the linker script overrides it. I also added a pdp11.sc file instead of using aout.sc so I could remove some sections that are extraneous for the pdp11 emulation. Comments are requested regarding the following design choices: - I have used the existing boolean ld_config_type::separate_code to indicate when --imagic is seen in the option parsing. To me its meaning seemed consistent with the new way I'm using it, but I could add another boolean if that would be preferred. - Rather than define another flag bit in bfd_target::object_flags, I'm copying the state of the separate_code boolean into a local variable in bfd/pdp11.c at _final_link() time for reference later in adjust_sizes_and_vmas() as the sections are written. - Since the --imagic format intentionally causes the .text and .data sections to occupy the same memory addresses, I had to set command_line.check_section_addresses = 0. Would that cause any other problems? - In my generated epdp11.c, the function name prefix is gldpdp11 rather than gld_pdp11 since that is how the code was written in the emulation from which I borrowed code. But I also saw the underscore included in a different emulation. Is one of these considered correct? The two one-line changes that I needed to make in common code are as follows: - I needed to add i_magic to enum aout_magic in bfd/libaout.h. - In ld/lexsup.c, I needed to set config.text_read_only to TRUE in case 'n'. This is the same as the default value of that boolean as initialized in ldmain.c so I assume my change won't affect any non-pdp11 emulation. I need this change so that my change of the default value for pdp11 will work. That boolean is initialized to FALSE or TRUE in case 'N' and case OPTION_NO_OMAGIC. I have not yet implemented changes to the documentation or test cases pending review of the code. The diff is attached. -- You are receiving this mail because: You are on the CC list for the bug.